[sqlalchemy] get unique property from model

2011-07-22 Thread Oliver Christen
hello all Im tring to find a way to extract from the model which colums have the attribute unique set, but after reading the documentation, exploring the source code and many many attempts, Im failing miserably. is there any way to do that? im using sqlalchemy 0.6.5 with the declarative syntax

[sqlalchemy] sqlalchemy and inheritance in postgres

2011-07-22 Thread jasonmclose
i seemed to have stumped SO, so i am trying with a repost here. here is an example of what our postgres database does (obviously, this is simplified): CREATE TABLE system (system_id SERIAL PRIMARY KEY, system_name VARCHAR(24) NOT NULL); CREATE TABLE file_entry(file_entry_id

[sqlalchemy] Re: py32 TypeError: unorderable types: str() int()

2011-07-22 Thread ddarko
To reproduce the error is needed: Python 3.2.0 SqlAlchemy 0.7.1 I use PostgreSQL 8.4 + psycopg2 2.4.2 but I think it does not matter. Contents of the table in the database before running the script. This is important. test2=# SELECT * from fl_opts ; key | value -+--- b | 3 (1 row)

[sqlalchemy] Re: get unique property from model

2011-07-22 Thread Oliver Christen
okay, I succeded to get the property I want: from sqlalchemy import UniqueConstraint from myproject import model for constraint in model.User.__table__.constraints: if isinstance(constraint, UniqueConstraint): for columns in constraint.columns: print 'column ' +

Re: [sqlalchemy] Re: py32 TypeError: unorderable types: str() int()

2011-07-22 Thread Michael Bayer
thanks. this is ticket #2228, issue is only in Python 3 if you want to stay on 2 for now, patch is attached in the meantime before the ticket is fixed. On Jul 22, 2011, at 9:19 AM, ddarko wrote: To reproduce the error is needed: Python 3.2.0 SqlAlchemy 0.7.1 I use PostgreSQL 8.4 +

[sqlalchemy] Re: py32 TypeError: unorderable types: str() int()

2011-07-22 Thread ddarko
THX On Jul 22, 4:13 pm, Michael Bayer mike...@zzzcomputing.com wrote: thanks.  this is ticket #2228, issue is only in Python 3 if you want to stay on 2 for now, patch is attached in the meantime before the ticket is fixed.  2228.patch 1KViewDownload On Jul 22, 2011, at 9:19 AM, ddarko

Re: [sqlalchemy] sqlalchemy and inheritance in postgres

2011-07-22 Thread Michael Bayer
On Jul 22, 2011, at 8:49 AM, jasonmclose wrote: my desire is to emulate this with sqlalchemy, Ok emulate, meaning, you no longer want to use Postgresql INHERITS and want SQLA to deal with the multiple tables ?Assuming I haven't forgotten how INHERITS works (I've not used it myself),

Re: [sqlalchemy] Re: get unique property from model

2011-07-22 Thread Michael Bayer
On Jul 22, 2011, at 9:22 AM, Oliver Christen wrote: okay, I succeded to get the property I want: from sqlalchemy import UniqueConstraint from myproject import model for constraint in model.User.__table__.constraints: if isinstance(constraint, UniqueConstraint): for columns in

[sqlalchemy] Re: sqlalchemy and inheritance in postgres

2011-07-22 Thread jasonmclose
i guess 'emulate' was the wrong word. i should have said 'design'. i do want the postgres inherits. i would like sqlalchemy to create these tables, and to tell postgres to use real inheritance. when the parent and child tables are created and filled with data, the parent table should be empty,

Re: [sqlalchemy] Re: sqlalchemy and inheritance in postgres

2011-07-22 Thread Michael Bayer
On Jul 22, 2011, at 11:26 AM, jasonmclose wrote: i guess 'emulate' was the wrong word. i should have said 'design'. i do want the postgres inherits. i would like sqlalchemy to create these tables, and to tell postgres to use real inheritance. when the parent and child tables are

[sqlalchemy] Not Expiring objects on rollbacks.

2011-07-22 Thread Moch Ramis
SQLAlchemy 7.1 I'm currently using sqlalchemy with a lot of begin/inserts/commits that allows me to make sure to have an atomic, stable save of my actions (but I only need a snapshot of my object at one time: my requests are consistent enough to avoid any database

Re: [sqlalchemy] Not Expiring objects on rollbacks.

2011-07-22 Thread Michael Bayer
On Jul 22, 2011, at 1:21 PM, Moch Ramis wrote: SQLAlchemy 7.1 I'm currently using sqlalchemy with a lot of begin/inserts/commits that allows me to make sure to have an atomic, stable save of my actions (but I only need a snapshot of my object at one time: my

Re: [sqlalchemy] Not Expiring objects on rollbacks.

2011-07-22 Thread Moch Ramis
2011/7/22 Michael Bayer mike...@zzzcomputing.com Here comes the problem: when an Integrity errors occurs, a rollback is done and every sqlalchemy records are expired, thus, the insert takes 3.42 seconds... and 3.41 seconds are spent on the restore snapshot function ... well the reason for

Re: [sqlalchemy] Not Expiring objects on rollbacks.

2011-07-22 Thread Michael Bayer
On Jul 22, 2011, at 5:08 PM, Moch Ramis wrote: 2011/7/22 Michael Bayer mike...@zzzcomputing.com Here comes the problem: when an Integrity errors occurs, a rollback is done and every sqlalchemy records are expired, thus, the insert takes 3.42 seconds... and 3.41 seconds are spent on

Re: [sqlalchemy] Re: sqlalchemy and inheritance in postgres

2011-07-22 Thread Michael Bayer
As I mentioned, just use single table inheritance against Parent - ChildX, Y. There are no other special settings on the SQLAlchemy side other than implicit_returning=False for the Table as PG's INHERITS doesn't seem to do what's expected for RETURNING parent.id. Full example, which is