Coming soon - Get a detailed view of why an account is flagged as spam!
view details

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.

1
Python MySQL connection lost inside Docker container
Post Body

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!

Author
Account Strength
100%
Account Age
14 years
Verified Email
Yes
Verified Flair
No
Total Karma
24,609
Link Karma
5,575
Comment Karma
19,026
Profile updated: 5 days ago
Posts updated: 7 months ago

Subreddit

Post Details

We try to extract some basic information from the post title. This is not always successful or accurate, please use your best judgement and compare these values to the post title and body for confirmation.
Posted
4 years ago