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
Post a Comment