Re: [sqlalchemy] Non negative integer column

2013-06-10 Thread Avishay Balderman
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

Re: [sqlalchemy] using contains_eager with multiple aliases?

2013-06-10 Thread Gerald Thibault
On Sunday, June 9, 2013 5:38:36 PM UTC-7, Michael Bayer wrote: On Jun 9, 2013, at 8:06 PM, Michael Bayer mik...@zzzcomputing.comjavascript: wrote: SELECT items.id AS items_id, items.item_type AS items_item_type, items.parent_id AS items_parent_id, items_ext.id AS items_ext_id,

Re: [sqlalchemy] Non negative integer column

2013-06-10 Thread Avishay Balderman
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:

Re: [sqlalchemy] Non negative integer column

2013-06-10 Thread Michael Bayer
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

Re: [sqlalchemy] Non negative integer column

2013-06-10 Thread Charlie Clark
Am 10.06.2013, 15:46 Uhr, schrieb Michael Bayer mike...@zzzcomputing.com: 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. FWIW

[sqlalchemy] Using SQL Expressions with existing declarative_base tables

2013-06-10 Thread Charlie Clark
Hi, I've got an application that I'm currently porting from MySQL to Postgres. The application itself has model classes derived from declarative_base but I have some housekeeping scripts that are currently hardcoded and which I like to move to SQL expressions to try and avoid

[sqlalchemy] [Q][0.7.9] All scoped sessions use ONE DB connection

2013-06-10 Thread Ladislav Lenart
Hello. We run our web application in cherrypy. I have just found that all our threads share *one* DB connection! A web page contains several AJAX calls, each queries the database. However only one runs at a time because the threads share DB connection. Notes to the code below: * We run postgres

Re: [sqlalchemy] Using SQL Expressions with existing declarative_base tables

2013-06-10 Thread Michael Bayer
On Jun 10, 2013, at 10:45 AM, Charlie Clark charlie.cl...@clark-consulting.eu wrote: Hi, I've got an application that I'm currently porting from MySQL to Postgres. The application itself has model classes derived from declarative_base but I have some housekeeping scripts that are

Re: [sqlalchemy] [Q][0.7.9] All scoped sessions use ONE DB connection

2013-06-10 Thread Michael Bayer
On Jun 10, 2013, at 11:46 AM, Ladislav Lenart lenart...@volny.cz wrote: I have no idea what is wrong. Please help me diagnose this! Note that OS monitor shows several cherrypy threads, each gets its share, so the cherrypy setup seems to be OK. class _SessionContext(object): def

Re: [sqlalchemy] Using SQL Expressions with existing declarative_base tables

2013-06-10 Thread Charlie Clark
Hi Mike, Am 10.06.2013, 18:38 Uhr, schrieb Michael Bayer mike...@zzzcomputing.com: I'm not sure here where the pain point is for you, just how to get access to something.execute()? Session has execute(), Engines and Connections can be stuck onto Sessions, there's any combination you'd

Re: [sqlalchemy] Using SQL Expressions with existing declarative_base tables

2013-06-10 Thread Michael Bayer
On Jun 10, 2013, at 12:46 PM, Charlie Clark charlie.cl...@clark-consulting.eu wrote: Hi Mike, Am 10.06.2013, 18:38 Uhr, schrieb Michael Bayer mike...@zzzcomputing.com: I'm not sure here where the pain point is for you, just how to get access to something.execute()? Session has

Re: [sqlalchemy] Using SQL Expressions with existing declarative_base tables

2013-06-10 Thread Charlie Clark
Am 10.06.2013, 18:54 Uhr, schrieb Michael Bayer mike...@zzzcomputing.com: Page.__table__.update() Duh! Just didn't see that. or agnostic of declarative: from sqlalchemy import inspect pages = inspect(Page).local_table pages.update() That looks nicer to me, thanks. Charlie -- Charlie

[sqlalchemy] Having __mapper_args__ order by columns defined in a superclass?

2013-06-10 Thread Daniel Grace
I'm converting some existing code from reflecting tables in the database to actually defining all of the columns. One of my primary reasons for doing this is being able to apply mixins and such to table definitions -- for instance, there's numerous lookup tables which all have id and name

Re: [sqlalchemy] Having __mapper_args__ order by columns defined in a superclass?

2013-06-10 Thread Michael Bayer
On Jun 10, 2013, at 2:00 PM, Daniel Grace thisgenericn...@gmail.com wrote: I'm converting some existing code from reflecting tables in the database to actually defining all of the columns. One of my primary reasons for doing this is being able to apply mixins and such to table definitions

Re: [sqlalchemy] Having __mapper_args__ order by columns defined in a superclass?

2013-06-10 Thread Daniel Grace
On Monday, June 10, 2013 11:13:09 AM UTC-7, Michael Bayer wrote: [...] Using 0.8 you can pull the actual copied column name from the __table__: class SortedLookupTable(LookupTable): __abstract__ = True @declared_attr def __mapper_args__(cls): return {'order_by':