V
V
VaniLuksh2020-08-26 15:34:09
Python
VaniLuksh, 2020-08-26 15:34:09

How do I resolve the sqlalchemy.exc.OperationalError when connecting to AWS RDS?

The sqlalchemy connection to the mysql database in AWS RDS is lost while running the program.
The error occurs after 10-15 minutes of idle time of the program.

sqlalchemy.exc.OperationalError: (pymysql.err.OperationalError) (2013, 'Lost connection to MySQL server during query ([WinError 10060] Попытка установить соединение была безуспешной, т.к. от другого компьютера за требуемое время не получен нужный отклик, или было разорвано уже установленное соединение из-за неверного отклика уже подключенного компьютера)')


The connection configuration looks like this:
engine = create_engine(
    'mysql+pymysql://admin:***"***rds.amazonaws.com:3306/***',
    echo=True,
    pool_recycle=3599)

Session = sessionmaker(bind=engine)
session = Session()


From the RDS side, the following parameters are applied in parameter groups:
connect_timeout = 3600
interactive_timeout = 3600
wait_timeout = 3600

Option groups - default:mysql-5-7

what could be the problem?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question