Questions tagged with Database

Content language: English

Sort by most recent

Browse through the questions and answers listed below or filter and sort to narrow down your results.

Connection reset by peer: Lost connection to MySQL server during query ([Errno 54]

I have a python application that is querying a MySQL Database (v `8.0.28`) hosted on AWS RDS. The code in the application looks something like this: import pymysql from sqlalchemy import create_engine user = 'usr1' pwd = 'pwd1' host = 'aaaaa.us-west-1.rds.amazonaws.com' port = 3306 database = 'db1' engine = create_engine("mysql+pymysql://{}:{}@{}/{}".format(user,pwd,host,database)) con = engine.connect() query = ''' select * from db1.tbl1 ''' df = pd.read_sql(query, con) con.close() The application triggers a query upon loading and query returns successful results. However, after a few minutes (2-3) of idle time, I get an error when it tries to query the DB again / establish a connection. Error traceback: File "/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/pymysql/connections.py", line 692, in _read_packet packet_header = self._read_bytes(4) File "/Applications/Anaconda/anaconda3/lib/python3.9/site-packages/pymysql/connections.py", line 738, in _read_bytes raise err.OperationalError( sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query ([Errno 54] Connection reset by peer)') [SQL: SELECT users.id AS users_id, users.fullname AS users_fullname, users.email AS users_email, users.password AS users_password, users.name AS users_name FROM users WHERE users.id = %(pk_1)s] [parameters: {'pk_1': 1}] (Background on this error at: https://sqlalche.me/e/14/e3q8) We're trying to isolate the issue to whether this in on the Application side or DB host side. https://aws.amazon.com/rds/mysql/
1
answers
0
votes
60
views
asked a month ago