python - sqlalchemy: How do I enforce date range on column? -


here how column looks

financial_day_of_month = column('financial_day_of_month', integer,                                     nullable=false, default=1) 

i want enforce min=1 , max=31 column. using postgresql backend

although can enforce logic on business layer, prefer enforce on persistence layer

is there way support it?

sounds you're looking check constraint, like:

class footable(declbase):     financial_day_of_month = column('financial_day_of_month', integer,                                         nullable=false, default=1)     __table_args__ = (         checkconstraint('financial_day_of_month between 1 , 31', name='check1'),         {}) 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -