2016-02-25 16 views
10

Próbuję dowiedzieć się, jak ustawić limit czasu połączenia w create_engine() dotąd próbowałem:Jak ustawić limit czasu połączenia w SQLAlchemy

create_engine(url, timeout=10) 

TypeError: Invalid argument(s) 'timeout' sent to create_engine(), using configuration PGDialect_psycopg2/QueuePool/Engine. Please check that the keyword arguments are appropriate for this combination of components.

create_engine(url, connection_timeout=10) 

TypeError: Invalid argument(s) 'connection_timeout' sent to create_engine(), using configuration PGDialect_psycopg2/QueuePool/Engine. Please check that the keyword arguments are appropriate for this combination of components.

create_engine(db_url, connect_args={'timeout': 10}) 

(psycopg2.OperationalError) invalid connection option "timeout"

create_engine(db_url, connect_args={'connection_timeout': 10}) 

(psycopg2.OperationalError) invalid connection option "connection_timeout"

create_engine(url, pool_timeout=10) 

Co należy zrobić?

Odpowiedz

19

Właściwy sposób jest to jeden (connect_timeout zamiast connection_timeout):

create_engine(db_url, connect_args={'connect_timeout': 10}) 

... i działa zarówno z PostgreSQL i MySQL

+2

Jaka jest wartość domyślną dla zmiennej connect_timeout (w ogóle i specyficzne dla bazy danych MySQL? – nivhanin

Powiązane problemy