File tree Expand file tree Collapse file tree 1 file changed +9
-0
lines changed
Expand file tree Collapse file tree 1 file changed +9
-0
lines changed Original file line number Diff line number Diff line change @@ -215,6 +215,10 @@ class PostgresEngine(Engine):
215215 When the engine starts, it will try and create these extensions
216216 in Postgres.
217217
218+ :param log_queries:
219+ If True, all SQL and DDL statements are printed out before being run.
220+ Useful for debugging.
221+
218222 """ # noqa: E501
219223
220224 __slots__ = ("config" , "extensions" , "pool" , "transaction_connection" )
@@ -226,9 +230,11 @@ def __init__(
226230 self ,
227231 config : t .Dict [str , t .Any ],
228232 extensions : t .Sequence [str ] = ["uuid-ossp" ],
233+ log_queries : bool = False ,
229234 ) -> None :
230235 self .config = config
231236 self .extensions = extensions
237+ self .log_queries = log_queries
232238 self .pool : t .Optional [Pool ] = None
233239 database_name = config .get ("database" , "Unknown" )
234240 self .transaction_connection = contextvars .ContextVar (
@@ -367,6 +373,9 @@ async def run_querystring(
367373 engine_type = self .engine_type
368374 )
369375
376+ if self .log_queries :
377+ print (querystring )
378+
370379 # If running inside a transaction:
371380 connection = self .transaction_connection .get ()
372381 if connection :
You can’t perform that action at this time.
0 commit comments