本文介绍了如何在SQLAlchemy中设置连接超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在尝试找出如何在 create_engine()中设置连接超时,到目前为止,我已经尝试过: create_engine(url,timeout = 10) TypeError:使用配置PGDialect_psycopg2 / QueuePool / Engine将无效的参数超时发送到create_engine()。请检查关键字参数是否适合此组件组合。 create_engine(url,connection_timeout = 10) TypeError:使用配置 PGDialect_psycopg2 / QueuePool / Engine将无效的参数'connection_timeout'发送到 create_engine()。请检查关键字参数是否适合此组件组合。 create_engine(db_url,connect_args = {'timeout':10}) (psycopg2.OperationalError)无效的连接选项超时 create_engine(db_url ,connect_args = {'connection_timeout':10}) (psycopg2。 OperationalError)无效的连接选项 connection_timeout create_engine(url,pool_timeout = 10) 我该怎么办?解决方案正确的方法是以下方法( connect_timeout 而不是 connection_timeout ): create_engine(db_url,connect_args = {'connect_timeout':10}) ...并且与Postgre一起使用s和MySQL ps :(超时以秒为单位) I'm trying to figure out how to set the connection timeout in create_engine(), so far I've tried: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)What should I do? 解决方案 The right way is this one (connect_timeout instead of connection_timeout):create_engine(db_url, connect_args={'connect_timeout': 10})...and it works with both Postgres and MySQLps: (the timeout is defined in seconds) 这篇关于如何在SQLAlchemy中设置连接超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
07-31 05:15