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
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
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)
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 ' +
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 +
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
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),
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
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,
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 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
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
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
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
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
15 matches
Mail list logo