2016-02-25 20 views
10

Sto cercando di capire come impostare il timeout di connessione in create_engine(), finora ho provato:Come impostare timeout di connessione in 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) 

Cosa devo fare?

risposta

19

Il modo giusto è questo uno (connect_timeout invece di connection_timeout):

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

... e funziona sia con Postgres e MySQL

+2

Qual è il valore di default per la variabile connect_timeout (in generale e specifico per il database MySQL? – nivhanin

Problemi correlati