【问题标题】:I got this error when i try to run the sqlite database by using python当我尝试使用 python 运行 sqlite 数据库时出现此错误
【发布时间】:2021-06-07 17:10:54
【问题描述】:

运行数据库时出现此错误:

UserWarning: Neither SQLALCHEMY_DATABASE_URI nor SQLALCHEMY_BINDS is set. Defaulting SQLALCHEMY_DATABASE_URI to "sqlite:///:memory:".
  warnings.warn(

它说问题出在此处:

def init_app(self, app):
    """This callback can be used to initialize an application for the
    use with this database setup.  Never use a database in the context
    of an application not initialized that way or connections will
    leak.
    """
    if (
        'SQLALCHEMY_DATABASE_URI' not in app.config and
        'SQLALCHEMY_BINDS' not in app.config
    ):
        warnings.warn(
            'Neither SQLALCHEMY_DATABASE_URI nor SQLALCHEMY_BINDS is set. '
            'Defaulting SQLALCHEMY_DATABASE_URI to "sqlite:///:memory:".'
        )

【问题讨论】:

  • 您应该显示您的代码,而不是最可能正确的 API 代码。

标签: python database sqlite


【解决方案1】:

在我们看到导致错误的代码之前,我无法确定这是否是正确的答案,如果错误我会更新我的答案,但是当您在应用程序已配置,当它试图找到它时,它是空白的,因为你没有配置它所以它使用默认的sqlite:///:memory:

但请更新您的帖子以包含您的代码,这样人们将能够提供帮助,而不是显示导入的代码

【讨论】:

    猜你喜欢
    • 2020-10-09
    • 2022-11-07
    • 1970-01-01
    • 2019-01-26
    • 2021-12-24
    • 1970-01-01
    • 2021-06-23
    • 2022-01-15
    • 2020-02-11
    相关资源
    最近更新 更多