This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I have a script that queries four separate MySQL databases (hosted elsewhere) using Python (with mysql-connector==2.2.9). I wrote and tested this script locally, and it runs without issue on my MacBook. I then created a Docker image using ubuntu:18.04 as the base image, and would like to run this script inside the container. Starting the container locally, it queries the first DB without issue, but I get the following error on the second DB:
mysql.connector.errors.InterfaceError: 2013: Lost connection to MySQL server during query
This only happens inside the container. The relevant code snippit:
for i, host in enumerate(hosts):
cnx = mysql.connector.connect(user=os.environ["DBUSER"],
password=os.environ["DBPASSWORD"],
host=host,
database=XXXXX
)
cursor = cnx.cursor()
cursor.execute(query)
df = pd.DataFrame(cursor.fetchall(), columns=columns)
Because the exact same code runs without issue outside of the container, I don't believe the issue is on the server-end.
Thanks!
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnpython...