Specify `statement_timeout` in Postgresql with sqlalchemy?

The following statement_timeout option works on some Postgresql databases, and on others Unsupported startup parameter: options. Why?

Perhaps this is the difference between Postgres 9.4 and 9.6? This works with previous servers and does not work with the latter.

from sqlalchemy import create_engine

# As is: Unsupported startup parameter: options
db_engine = create_engine("postgresql://user:pw@host/database",
    connect_args={"options": "-c statement_timeout=1000"})

with db_engine.connect() as db_connection:
    print("got it")

In particular, I get:

sqlalchemy.exc.OperationalError: (psycopg2.OperationalError) ERROR:  Unsupported startup parameter: options
+4
source share

Source: https://habr.com/ru/post/1682528/


All Articles