我正在为我的后端 API 服务器使用 python。我的后端使用 SQLALCHEMY 连接到 DISTANT Postgres 数据库(没有flask-sqlalchemy,因为即使没有flask上下文我也需要该连接器(用于其他特定任务)
我的问题是:有时,我的 SQLConnector 崩溃了,说:
(psycopg2.OperationalError) server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
Run Code Online (Sandbox Code Playgroud)
这是随机发生的。我尝试使用刷新机制修复它,但没有成功......(为了记录,它在 Docker 中)
我想要什么 ? 获取一个 python 软件 (sqlalchemy) 定期从远程数据库 (postgres) 抓取数据,而不会随着时间的推移随机断开连接
我试图修复它 尝试在错误时自动重新连接,并在没有成功或正确的代码片段的情况下更改引擎连接
我在哪里? 我被卡住了,我不知道如何在我想要的时候重现这个错误(为了更快的测试/调试过程)而不是我的 sql 连接器上那些烦人的断开连接
(psycopg2.OperationalError) server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
[SQL: 'INSERT INTO scan_oee (uniqid, id_kanban, created_at, finished, debug) VALUES (%(uniqid)s, %(id_kanban)s, …Run Code Online (Sandbox Code Playgroud)