如何使用 peewee orm 从模式中的特定 table 创建模型? (FastAPI 项目)

How to create a model from a specific table that is inside a schema using peewee orm? (FastAPI Project)

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

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

但我只需要创建特定 table 的模型,它位于模式中。

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

使用-t选项提及table(s)

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