[sqlalchemy] Re: partial rollback

2013-02-17 Thread rurpy
On Sunday, February 17, 2013 10:06:33 AM UTC-7, ru...@yahoo.com wrote: > > [...] > My question is how is this normally managed in typical > application code? A flush can potentially occur anytime a > mapped attribute is changed. Do I need to wrap every such > place in my code in a try/except to

[sqlalchemy] partial rollback

2013-02-17 Thread rurpy
When sqlalchemy flushes pending changes to the database, sometimes those changes fail and raise a DatabaseError (eg, trying to delete a row that is referenced by a foreign key when the ON DELETE action is NO ACTION or RESTRICT). When that happens sqlalchemy enters a rollback state and requires th

Re: [sqlalchemy] corresponding attribute not updated

2013-02-17 Thread rurpy
On Friday, February 15, 2013 7:36:22 AM UTC-7, Michael Bayer wrote: > On Feb 14, 2013, at 5:18 PM, ru...@yahoo.com wrote: > > What is the best way to get the .Person attribute updated to match > > a new value assigned to .person? > > > > items = session.query(Task).order_by(Task.id).all() >

[sqlalchemy] corresponding attribute not updated

2013-02-14 Thread rurpy
I have two tables, "task" and "person", and m:m join table between them, "t2p". The "Task" object has a relationship, "t2p_" that is a list of all the associated "t2p" rows. Each of those has a "Person" attribute for the associated "person" row. I get a "table" row. I then change the t2p_[n].p

Re: [sqlalchemy] self-ref relationship with refletion?

2013-02-07 Thread rurpy
On Thursday, February 7, 2013 2:10:33 PM UTC-7, Michael Bayer wrote: > > use a quoted expression that isn't evaluated until mapper configuration > time: > > parent = relationship("Test", remote_side="Test.id") > That did it, thanks. -- You received this message because you are subscribed to

[sqlalchemy] self-ref relationship with refletion?

2013-02-07 Thread rurpy
How does one define a self-referential relationship when using declarative objects and reflection? Based on http://docs.sqlalchemy.org/en/rel_0_8/orm/relationships.html#adjacency-list-relationships I wrote the code below but when I run it I get an exception when the session.query() line is

Re: [sqlalchemy] logging

2013-02-05 Thread rurpy
On 02/04/2013 11:30 AM, Michael Bayer wrote: > > On Feb 4, 2013, at 1:04 AM, ru...@yahoo.com > wrote: > >> simply didn't get from the docs. Like the fact that I could create >> a mapped object simply with >> >> class User: pass >> >> rather than explicitly specifying a

[sqlalchemy] Re: Tracking changes made to mapped objects

2013-02-03 Thread rurpy
Thanks much. I will look into the options you suggest. On 02/01/2013 11:16 AM, Michael Bayer wrote: > attribute history features are available via get_history():> > > http://docs.sqlalchemy.org/en/rel_0_8/orm/session.html?highlight=get_history#sqlalchemy.orm.attributes.get_history>> > Howev

Re: [sqlalchemy] logging

2013-02-03 Thread rurpy
On 02/01/2013 11:10 AM, Michael Bayer wrote: > On Feb 1, 2013, at 1:06 PM, ru...@yahoo.com > wrote: >> I am working from Copeland's Sqlalchemy book > > please do not use this book. It is many years out of date, and was> in > > fact already outdated the day it was

Re: [sqlalchemy] Error deleting mapped object

2013-02-03 Thread rurpy
On 02/01/2013 11:08 AM, Michael Bayer wrote: > On Feb 1, 2013, at 1:02 PM, ru...@yahoo.com wrote: >> When I delete[*1] a mapped object (a Title()) that is on the many>> side of >> a 1:m relationship (in sqlalchemy 0.8.0b2, Python 3.3), I>> get the >> following erro

[sqlalchemy] logging

2013-02-01 Thread rurpy
I am working from Copeland's Sqlalchemy book and he describes giving an "echo_uow" argument to Session() to enable unit-of- work messages. But perhaps the book refers to an old version of SA because I can find no documentation on that parameter (and both Session and sessionmaker reject it as "unex

[sqlalchemy] Re: Tracking changes made to mapped objects

2013-02-01 Thread rurpy
No suggestions? On Wednesday, January 30, 2013 1:31:33 PM UTC-7, ru...@yahoo.com wrote: > > [...] > How can I determine what [attributes] has been changed, even after > a flush? (Or should I disable autoflushing?) > > How to revert some changes (but not all; for that I > would just do a rollba

[sqlalchemy] Error deleting mapped object

2013-02-01 Thread rurpy
When I delete[*1] a mapped object (a Title()) that is on the many side of a 1:m relationship (in sqlalchemy 0.8.0b2, Python 3.3), I get the following error when I do a session.commit(): [...earlier part of traceback elided...] File "/usr/local/lib/python3.3/site-packages/sqlalchemy/orm/sync.

[sqlalchemy] Tracking changes made to mapped objects

2013-01-30 Thread rurpy
I'm using Sqlalchemy for the first time and am slowly figuring out most of what I need. However there is one aspect I would like some advice about. I have a GUI program that gets some number of items (say data about movies for example) from a database and lets the user edit them including forei