烧瓶 - postgresql-关系不存在

发布于 2025-02-11 05:33:02 字数 840 浏览 2 评论 0原文

我正在尝试为烧瓶应用程序创建新数据库(从SQLite迁移到PostgreSQL)。当应用启动并调用函数create_all()应用程序发送错误关系“用户”不存在“不存在”为以下事件侦听器:

@event.listen_for(User.__table__, 'after_create')
def create_default_user(*args, **kwargs): 
    print("Create User Table - Default User")
    db.session.add(User(username="admin", email="[email protected]", password=generate_password_hash("admin", "sha256")))
    db.session.commit()

如果我创建新的SQLITE DB (“ sqlite://db.sqlite” )都可以正常工作,但是如果我想启动PostgreSQL数据库(“ Postgresql:// /l/电子邮件保护“ class =” __ cf_email__'data-cfemail =“ E08D99939590859290819393978F9284AA0D1D1D7D2CED1D7CED1D7CED1D7CED0CED2”

>错误 ?

I am trying to create new database (migrate from sqlite to postgresql) for my flask App. When the app starts and call the function create_all() the app send the error relation "user" does not exists" for the following event listener :

@event.listen_for(User.__table__, 'after_create')
def create_default_user(*args, **kwargs): 
    print("Create User Table - Default User")
    db.session.add(User(username="admin", email="[email protected]", password=generate_password_hash("admin", "sha256")))
    db.session.commit()

If I create new sqlite db ("sqlite://db.sqlite") all works fine, But if i want to initiate postgresql database ("postgresql://test:[email protected]:5432/flask") i got the error.

Someone know where i did a mistake ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文