I define a lot of model classes using peewee. ClassName.create_table() can generate the table,but only one table. How could I create all tables using a single state
ClassName.create_table()
Extending coleifer's answer with the assumption that all tables are grouped in one module:
import inspect import peewee import tables models = [ obj for name, obj in inspect.getmembers( tables, lambda obj: type(obj) == type and issubclass(obj, peewee.Model) ) ] peewee.create_model_tables(models)