[英]I got this error when i try to run the sqlite database by using python
運行數據庫時出現此錯誤:
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:".'
)
在我們看到導致錯誤的代碼之前,我無法確定這是否是正確的答案,如果錯誤我會更新我的答案,但是當您在配置應用程序之前調用init_app()
時往往會出現該問題,當它試圖找到它時,它是空白的,因為你沒有配置它,所以它使用默認的sqlite:///:memory:
但是請更新您的帖子以包含您的代碼,這樣人們就可以提供幫助,而不是顯示導入的代碼
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.