2016-02-25 8 views
10

Ich versuche, um auf Figur, wie in create_engine() die Verbindung Timeout zu setzen, so weit habe ich versucht:Wie Verbindungs-Timeout 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) 

Was soll ich tun?

Antwort

19

Der richtige Weg ist dies ein (connect_timeout statt connection_timeout):

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

... und es funktioniert sowohl mit Postgres und MySQL

+2

Was den Standardwert für die connect_timeout Variable ist (im Allgemeinen und spezifisch für MySQL-Datenbank? – nivhanin

Verwandte Themen