2016-02-25 46 views
10

我試圖找出如何設置連接超時在create_engine()連接超時,到目前爲止,我已經試過:如何設置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) 

我該怎麼辦?

回答

19

正確的做法是這樣的一個(的connect_timeout代替connection_timeout):

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

...這兩者的Postgres和MySQL

+2

什麼是對connect_timeout變量的默認值(一般和特定於MySQL數據庫? – nivhanin

相關問題