set default pool_recycle if using mysql

This commit is contained in:
Min RK
2016-03-08 10:58:18 +01:00
parent a0501c6ee4
commit 74e558dad2

View File

@@ -378,6 +378,8 @@ def new_session_factory(url="sqlite:///:memory:", reset=False, **kwargs):
"""Create a new session at url"""
if url.startswith('sqlite'):
kwargs.setdefault('connect_args', {'check_same_thread': False})
elif url.startswith('mysql'):
kwargs.setdefault('pool_recycle', 60)
if url.endswith(':memory:'):
# If we're using an in-memory database, ensure that only one connection