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

add possibility to set pool_pre_ping in configuration #600

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ A list of configuration keys currently understood by the extension:
different default timeout value. For more
information about timeouts see
:ref:`timeouts`.
``SQLALCHEMY_POOL_PRE_PING`` The “pre ping” feature will normally emit
SQL equivalent to “SELECT 1” each time a
connection is checked out from the pool;
if an error is raised that is detected as
a “disconnect” situation, the connection
will be immediately recycled, and all other
pooled connections older than the current
time are invalidated, so that the next time
they are checked out, they will also be
recycled before use.
``SQLALCHEMY_MAX_OVERFLOW`` Controls the number of connections that
can be created after the pool reached
its maximum size. When those additional
Expand Down
2 changes: 2 additions & 0 deletions flask_sqlalchemy/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -787,6 +787,7 @@ def init_app(self, app):
app.config.setdefault('SQLALCHEMY_POOL_SIZE', None)
app.config.setdefault('SQLALCHEMY_POOL_TIMEOUT', None)
app.config.setdefault('SQLALCHEMY_POOL_RECYCLE', None)
app.config.setdefault('SQLALCHEMY_POOL_PRE_PING', None)
app.config.setdefault('SQLALCHEMY_MAX_OVERFLOW', None)
app.config.setdefault('SQLALCHEMY_COMMIT_ON_TEARDOWN', False)
track_modifications = app.config.setdefault(
Expand Down Expand Up @@ -819,6 +820,7 @@ def _setdefault(optionkey, configkey):
_setdefault('pool_size', 'SQLALCHEMY_POOL_SIZE')
_setdefault('pool_timeout', 'SQLALCHEMY_POOL_TIMEOUT')
_setdefault('pool_recycle', 'SQLALCHEMY_POOL_RECYCLE')
_setdefault('pool_pre_ping', 'SQLALCHEMY_POOL_PRE_PING')
_setdefault('max_overflow', 'SQLALCHEMY_MAX_OVERFLOW')

def apply_driver_hacks(self, app, info, options):
Expand Down