【问题标题】:How to create a model from a specific table that is inside a schema using peewee orm? (FastAPI Project)如何使用 peewee orm 从架构内的特定表创建模型? (FastAPI 项目)
【发布时间】:2021-09-08 21:03:14
【问题描述】:

我需要使用 orm peewee 从我的数据库中的模式内的表创建模型,我找到了一个命令,允许我在 postgresql 中从我的数据库中生成所有模型

python -m pwiz -e postgresql db_name > db_name_models.py

但我只需要创建特定表的模型,该表位于模式内。

【问题讨论】:

    标签: python postgresql fastapi peewee


    【解决方案1】:

    您可以使用提供的命令行选项 http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#pwiz

    使用 -t 选项提及表格

    python -m pwiz -e postgresql db_name  -t tablename, tablname2 > db_name_models.py
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-23
      • 1970-01-01
      • 2021-05-28
      • 2013-12-28
      • 1970-01-01
      • 1970-01-01
      • 2021-02-06
      • 2019-03-10
      相关资源
      最近更新 更多