I prefer to have a server side solution... but cant find a generic one.

On Monday, June 10, 2013 4:46:54 PM UTC+3, Michael Bayer wrote:
>
> Oh.  Well a python side rule is very different from a server side rule, 
> but if app side is all you need then sure you have a lot of options there. 
>   Use a TypeDecorator, check the docs there are many examples.
>
> Sent from my iPhone
>
> On Jun 10, 2013, at 4:30 AM, Avishay Balderman 
> <bald...@gmail.com<javascript:>> 
> wrote:
>
> 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 <bald...@gmail.com> 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 sqlalchemy+...@googlegroups.com.
>>> To post to this group, send email to sqlal...@googlegroups.com.
>>> 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 sqlalchemy+...@googlegroups.com <javascript:>.
> To post to this group, send email to sqlal...@googlegroups.com<javascript:>
> .
> 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 sqlalchemy+unsubscr...@googlegroups.com.
To post to this group, send email to sqlalchemy@googlegroups.com.
Visit this group at http://groups.google.com/group/sqlalchemy?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to