The following Python code snippet illustrates the issue:
print(\"starting\")
# I am trying to configure a query/command timeout of one second.
# sqlalchemy
You can set configuration values like statement_timeout via the options parameter in libpq. You can access this parameter in psycopg2
as part of the connect call. You can pass additional parameters to the connect
call from SQLAlchemy via the connect_args parameter. So, putting it all together:
engine = create_engine(..., connect_args={"options": "-c statement_timeout=1000"})