How about using UserDefinedType http://docs.sqlalchemy.org/en/rel_0_8/core/types.html#sqlalchemy.types.UserDefinedType and declare a type 'NonNegativeInteger'. Will it be enough to protect the table from negative integers?
On Monday, June 10, 2013 10:19:21 AM UTC+3, Avishay Balderman wrote: > > Hi > I am looking for a portable solution - A solution that will work when I > switch from DB A to DB B. > so I do not want to include any MySQL specific code. > CheckConstraint looks promising.. but you mentioned it is not supported by > MySQL. > > Any other ideas? > > Thanks > > Avishay > > On Monday, June 10, 2013 3:08:09 AM UTC+3, Michael Bayer wrote: >> >> have you considered just using an UNSIGNED INT ? MySQL offers support >> for such types. >> >> The CHECK constraint is a good way to go as well, but unfortunately I >> believe MySQL does not actually enforce CHECK constraints (funny, huh?) . >> Here's an SO question regarding that issue: >> http://stackoverflow.com/questions/5807231/mysql-check-constraint-alternative >> . >> >> >> >> >> On Jun 9, 2013, at 8:14 AM, Avishay Balderman <[email protected]> wrote: >> >> Hi >> I would like to create a table with an integer column. >> This column value must be >= 0. >> How can I enforce it using table defintion? >> i have looked here and it looks fine. >> >> http://docs.sqlalchemy.org/en/rel_0_8/core/schema.html?highlight=checkconstraint#sqlalchemy.schema.CheckConstraint >> Will it work against any DB? >> My backing DB is MySQL. >> >> Thanks >> >> Avishay >> >> -- >> You received this message because you are subscribed to the Google Groups >> "sqlalchemy" group. >> To unsubscribe from this group and stop receiving emails from it, send an >> email to [email protected]. >> To post to this group, send email to [email protected]. >> Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> >> >> -- You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/sqlalchemy?hl=en. For more options, visit https://groups.google.com/groups/opt_out.
