coleifer / peewee

a small, expressive orm -- supports postgresql, mysql, sqlite and cockroachdb
http://docs.peewee-orm.com/
MIT License
11.18k stars 1.37k forks source link

Cant create PK via Meta class OUTSIDE of Model class defenition #2867

Closed MikhailDunaev closed 7 months ago

MikhailDunaev commented 7 months ago

It seams strange that I can not config primary key outside the Model class.

class MyModel(BaseModel): some_fld ... class Meta: primary_key = False

my_meta = MyModel._meta my_meta.primary_key = CompositeKey('id', 'some_fld')

I want to config tables by myself in such a way (partitionig).

coleifer commented 7 months ago

You'll need to figure it out yourself, but you can dynamically create the classes either inside a function or using type().