Search code examples
pythonpostgresqlfastapipeewee

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


I need to create a model from a table that is inside a schema in my db using the orm peewee, I found a command that allows me to generate all models from my database in postgresql

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

but I only need to create the model of a specific table, which is inside a schema.


Solution

  • You can use the command line option provided http://docs.peewee-orm.com/en/latest/peewee/playhouse.html#pwiz

    Use the -t option to mention the table(s)

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