【问题标题】:SQLAlqhemy database operational error 11001SQLAlqhemy 数据库操作错误 11001
【发布时间】:2021-07-06 11:17:29
【问题描述】:

当我尝试使用命令 db.create_all() 为我的烧瓶应用程序构建我的 sqlalchemy 数据库(使用 flask-sqlalchemy)时,我遇到了一个问题,我无法解决这个问题,这是错误代码:

  File "c:\users\paulo\desktop\python\projects\paper_note\venv\lib\site-packages\pymysql\connections.py", line 614, in connect
    (self.host, self.port), self.connect_timeout, **kwargs
  File "C:\Program Files\Python37\lib\socket.py", line 707, in create_connection
    for res in getaddrinfo(host, port, 0, SOCK_STREAM):
  File "C:\Program Files\Python37\lib\socket.py", line 752, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 11001] getaddrinfo failed

During handling of the above exception, another exception occurred:

  File "c:\users\paulo\desktop\python\projects\paper_note\venv\lib\site-packages\sqlalchemy\engine\default.py", line 509, in connect
    return self.dbapi.connect(*cargs, **cparams)
  File "c:\users\paulo\desktop\python\projects\paper_note\venv\lib\site-packages\pymysql\connections.py", line 353, in __init__
    self.connect()
  File "c:\users\paulo\desktop\python\projects\paper_note\venv\lib\site-packages\pymysql\connections.py", line 664, in connect
    raise exc
pymysql.err.OperationalError: (2003, "Can't connect to MySQL server on 'dbserver' ([Errno 11001] getaddrinfo failed)")

【问题讨论】:

  • 好像是数据库连接错误;介意分享一下你是如何与它建立联系的吗?
  • 请提供代码,而不仅仅是错误。您的数据库服务器的主机名是什么?你的本地机器可以访问它吗?
  • 对不起,我忘了回答这个问题,我已经修复了这个错误,我的数据库 url 不正确

标签: python python-3.x flask sqlalchemy flask-sqlalchemy


【解决方案1】:

我希望这对其他人有帮助,为了解决这个错误,我验证了我的数据库连接 URL,但这是不正确的。

【讨论】:

    猜你喜欢
    • 2016-09-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-12-09
    • 2018-09-03
    • 2019-09-26
    • 1970-01-01
    相关资源
    最近更新 更多