sqlalchemy数据库查询每次都会超时

时间:2017-07-21 08:55:56

标签: sqlalchemy python-3.4

希望有人可以提供帮助!

python3.4

我在托管多个mysql数据库的本地计算机上运行了以下脚本:

from sqlalchemy import create_engine, MetaData, inspect
username = ***
password = ***
port = '22'
database = db_name
engine = create_engine('mysql+mysqlconnector://' + username +':' + password + '@127.0.0.1:' + port + '/' + database)

无论我从这里做什么与数据库交互,它都会超时(每次都有相同的错误)。例如:

inspector = inspect(engine) or metadata.reflect(engine) (run separately)

都将返回:

Traceback (most recent call last):
  File "/usr/local/lib/python3.4/dist-packages/SQLAlchemy-1.2.0b2dev-py3.4-linux-x86_64.egg/sqlalchemy/pool.py", line 1165, in _do_get
  File "/usr/local/lib/python3.4/dist-packages/SQLAlchemy-1.2.0b2dev-py3.4-linux-x86_64.egg/sqlalchemy/util/queue.py", line 145, in get
    self.not_full.wait(remaining)
sqlalchemy.util.queue.Empty
/*whole bunch other error messages here*/
sqlalchemy.exc.InterfaceError: (mysql.connector.errors.InterfaceError) 2013: Lost connection to MySQL server during query

我也试过

engine = create_engine('mysql+pymysql://username:password@127.0.0.1:port/database')

具有相同的结果。

非常感谢!

0 个答案:

没有答案