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

support 'echo_pool' option when creating the engine. #208

Closed
wants to merge 3 commits into from
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/config.rst
Expand Up @@ -26,6 +26,9 @@ A list of configuration keys currently understood by the extension:
``SQLALCHEMY_ECHO`` If set to `True` SQLAlchemy will log all
the statements issued to stderr which can
be useful for debugging.
``SQLALCHEMY_ECHO_POOL`` If set to `True`, the connection pool will
log all checkouts/checkins to the logging
stream, which defaults to sys.stdout
``SQLALCHEMY_RECORD_QUERIES`` Can be used to explicitly disable or
enable query recording. Query recording
automatically happens in debug or testing
Expand Down
1 change: 1 addition & 0 deletions examples/hello.cfg
@@ -1,4 +1,5 @@
SQLALCHEMY_DATABASE_URI = 'sqlite:////tmp/test.db'
SQLALCHEMY_ECHO = False
SQLALCHEMY_ECHO_POOL = False
SECRET_KEY = '\xfb\x12\xdf\xa1@i\xd6>V\xc0\xbb\x8fp\x16#Z\x0b\x81\xeb\x16'
DEBUG = True
4 changes: 4 additions & 0 deletions flask_sqlalchemy/__init__.py
Expand Up @@ -488,6 +488,7 @@ def get_engine(self):
with self._lock:
uri = self.get_uri()
echo = self._app.config['SQLALCHEMY_ECHO']
echo_pool = self._app.config['SQLALCHEMY_ECHO_POOL']
if (uri, echo) == self._connected_for:
return self._engine
info = make_url(uri)
Expand All @@ -496,6 +497,8 @@ def get_engine(self):
self._sa.apply_driver_hacks(self._app, info, options)
if echo:
options['echo'] = True
if echo_pool:
options['echo_pool'] = True
self._engine = rv = sqlalchemy.create_engine(info, **options)
if _record_queries(self._app):
_EngineDebuggingSignalEvents(self._engine,
Expand Down Expand Up @@ -720,6 +723,7 @@ def init_app(self, app):
app.config.setdefault('SQLALCHEMY_BINDS', None)
app.config.setdefault('SQLALCHEMY_NATIVE_UNICODE', None)
app.config.setdefault('SQLALCHEMY_ECHO', False)
app.config.setdefault('SQLALCHEMY_ECHO_POOL', False)
app.config.setdefault('SQLALCHEMY_RECORD_QUERIES', None)
app.config.setdefault('SQLALCHEMY_POOL_SIZE', None)
app.config.setdefault('SQLALCHEMY_POOL_TIMEOUT', None)
Expand Down