Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于 MySQL 连接失效的问题 #11

Closed
Ed-XCF opened this issue Jan 23, 2021 · 0 comments
Closed

关于 MySQL 连接失效的问题 #11

Ed-XCF opened this issue Jan 23, 2021 · 0 comments

Comments

@Ed-XCF
Copy link
Contributor

Ed-XCF commented Jan 23, 2021

sqlalchemy 有三个 配置 可能可以帮助解决问题。具体的设置值还需要更多资料和实践支持:

增加连接池内连接数
:param pool_size=5: the number of connections to keep open
inside the connection pool. This used with
:class:~sqlalchemy.pool.QueuePool as
well as :class:~sqlalchemy.pool.SingletonThreadPool. With
:class:~sqlalchemy.pool.QueuePool, a pool_size setting
of 0 indicates no limit; to disable pooling, set poolclass to
:class:~sqlalchemy.pool.NullPool instead.

定期完全重置连接池
:param pool_recycle=-1: this setting causes the pool to recycle
connections after the given number of seconds has passed. It
defaults to -1, or no timeout. For example, setting to 3600
means connections will be recycled after one hour. Note that
MySQL in particular will disconnect automatically if no
activity is detected on a connection for eight hours (although
this is configurable with the MySQLDB connection itself and the
server configuration as well).

连接前进行 " 预 ping "(在直接使用 pymysql 编程的场景下,它是一种可以工作的策略,尚不清楚对运行中的事务的影响)
:param pool_pre_ping: boolean, if True will enable the connection pool
"pre-ping" feature that tests connections for liveness upon
each checkout.

@Ed-XCF Ed-XCF closed this as completed Jan 23, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant