RE: [sqlalchemy] update existing row

2011-08-01 Thread King Simon-NFHD78
vitsin wrote: hi, can't figure out why raw SQL works fine, but update() is not working: 1.working raw SQL: self.session.execute(update public.my_table set status='L',updated_at=now() where my_name='%s' % (self.my_name)) 2.non working update() from Alchemy: s = aliased(MyTable) query =

[sqlalchemy] Updating user interface after rollback (using after_rollback SessionExtension?)

2011-08-01 Thread Torsten Landschoff
Hello world, I am tearing my hair about my SQLAlchemy usage in a GUI application, especially to get it error tolerant. Usually the GUI filters user inputs before they are thrown at SQLAlchemy to store it into the database. If that fails, however, it can happen that data is thrown at the database

[sqlalchemy] Relationship spanning on multiple tables

2011-08-01 Thread neurino
I'm trying to get some relationships spanning on multiple tables (4 or 5). While I got the `4 tables` one working on first attempt (I was surpized I could...) I can't get the `5 tables` one to work while the code is almost the same. Moreover with the first relationship if I add adding

[sqlalchemy] Building hierarchy tree in reverse

2011-08-01 Thread Vlad K.
Hi. I have a problem and am not sure where to begin. I need to construct a hierarchy tree, something like adjacency_list but in reverse. More precisely, I need entire branch but only the branch containing given node ID. In practice, I need this for a product category tree menu which shows

[sqlalchemy] Are data really in database using session.comit

2011-08-01 Thread Eduardo
Daer all I have a following problem : Session = sessionmaker(bind=engine) session = Session() for item in items: item1 = session.query(item) if len(item1)==0: session.add(item1) session.commit() The session is valid for a loop and I write items in a database during each

Re: [sqlalchemy] Updating user interface after rollback (using after_rollback SessionExtension?)

2011-08-01 Thread Michael Bayer
On Aug 1, 2011, at 6:25 AM, Torsten Landschoff wrote: Hello world, I am tearing my hair about my SQLAlchemy usage in a GUI application, especially to get it error tolerant. Usually the GUI filters user inputs before they are thrown at SQLAlchemy to store it into the database. If that

Re: [sqlalchemy] Are data really in database using session.comit

2011-08-01 Thread Michael Bayer
On Aug 1, 2011, at 11:07 AM, Eduardo wrote: Daer all I have a following problem : Session = sessionmaker(bind=engine) session = Session() for item in items: item1 = session.query(item) if len(item1)==0: session.add(item1) session.commit() The session is

[sqlalchemy] Simple one-to-one translation with hybrid_attribute

2011-08-01 Thread Ross Vandegrift
Hello everyone, Trying to use hybrid_attribute to provide friendly names for integers representing object states. Storage and retrieval works fine, but I can't get filtering working. I want the translation to happen on the Python side prior to filling in the query parameters, but

Re: [sqlalchemy] Relationship spanning on multiple tables

2011-08-01 Thread Michael Bayer
'transm_limit': relationship(SurfaceRes, single_parent=True, #uselist=False, #primaryjoin=and_( #user_stratigraphies.c.id_prov==provinces.c.id, #provinces.c.id_cz==transm_limits.c.id_cz, #

Re: [sqlalchemy] Simple one-to-one translation with hybrid_attribute

2011-08-01 Thread Michael Bayer
On Aug 1, 2011, at 5:08 PM, Ross Vandegrift wrote: Hello everyone, Trying to use hybrid_attribute to provide friendly names for integers representing object states. Storage and retrieval works fine, but I can't get filtering working. I want the translation to happen on the Python side

Re: [sqlalchemy] Simple one-to-one translation with hybrid_attribute

2011-08-01 Thread Ross Vandegrift
On Mon, 2011-08-01 at 17:22 -0400, Michael Bayer wrote: You're looking to convert from int-string using a mapping in a SQL expression, so I think you'd need to write @state.expression as a CASE statement. from sqlalchemy import case @state.expression def state(self):

[sqlalchemy] Integrity error when using association_proxy - one of the foreign keys is missing

2011-08-01 Thread somewhatofftheway
Hi, I'm trying to convert a 'simple' many-to-many relationship to an association object in order to allow the relationship to have attributes. I've followed the code in examples/association/ proxied_association.py fairly closely (or so I thought) but it isn't working for me. As an example, let's

Re: [sqlalchemy] Integrity error when using association_proxy - one of the foreign keys is missing

2011-08-01 Thread Michael Bayer
On Aug 1, 2011, at 8:34 PM, somewhatofftheway wrote: Hi, I'm trying to convert a 'simple' many-to-many relationship to an association object in order to allow the relationship to have attributes. I've followed the code in examples/association/ proxied_association.py fairly closely (or so

[sqlalchemy] Re: Building hierarchy tree in reverse

2011-08-01 Thread Gunnlaugur Briem
You could look for recursive CTE (Common Table Expressions), if your database engine supports such queries. See e.g. http://www.postgresql.org/docs/8.4/static/queries-with.html for PostgreSQL. That allows arbitrary-depth queries, as opposed to join chains that have to assume a fixed depth. You