[sqlalchemy] Subtransactions

2010-11-01 Thread Michael Hipp
If I do this: item1 = Item() # a new item self.sess.add(item1) self.sess.begin(subtransactions=True) # sub transaction item2 = Item() # another self.sess.add(item2) self.sess.rollback() # rollback sub trans cnt = self.sess.query(Item).count() # how many? That

Re: [sqlalchemy] Subtransactions

2010-11-01 Thread Michael Bayer
nested = uses SAVEPOINT. This is the technique the average user wants to use.Background: http://en.wikipedia.org/wiki/Savepoint subtransactions = a code nesting technique. Is only enabled via a flag so that the feature isn't inadvertently used, since it is generally an advanced

Re: [sqlalchemy] Subtransactions

2010-11-01 Thread Michael Hipp
On 11/1/2010 10:19 AM, Michael Bayer wrote: SAVEPOINT. This is the technique the average user wants to use. Thanks for that. Pertinent documentation: begin(): When a rollback is issued, the subtransaction will directly roll back the innermost *real* transaction. rollback(): This method rolls

Re: [sqlalchemy] Subtransactions

2010-11-01 Thread Michael Bayer
OK I think in this case, as in many others, is that subtransactions are not an easy to learn feature, hence it is controlled by a flag that is off by default. With features like that, there is simply no way to write a paragraph that will unconditionally impart the correct meaning - only

Re: [sqlalchemy] Subtransactions

2010-11-01 Thread Chris Withers
On 01/11/2010 15:19, Michael Bayer wrote: nested = uses SAVEPOINT. This is the technique the average user wants to use. Background: http://en.wikipedia.org/wiki/Savepoint How do you roll back to a savepoint in SA? Chris -- Simplistix - Content Management, Batch Processing Python Consulting

Re: [sqlalchemy] Subtransactions

2010-11-01 Thread Michael Bayer
*headslap* (note to observers - Chris and I are buds ! I kid) http://www.sqlalchemy.org/docs/orm/session.html#using-savepoint On Nov 1, 2010, at 1:05 PM, Chris Withers wrote: On 01/11/2010 15:19, Michael Bayer wrote: nested = uses SAVEPOINT. This is the technique the average user wants

Re: [sqlalchemy] Subtransactions

2010-11-01 Thread Michael Hipp
On 11/1/2010 11:33 AM, Michael Bayer wrote: OK I think in this case, as in many others, is that subtransactions are not an easy to learn feature, hence it is controlled by a flag that is off by default. ... ... for features that aren't intended for typical use Then perhaps say that. This

Re: [sqlalchemy] Subtransactions

2010-11-01 Thread Michael Bayer
On Nov 1, 2010, at 2:08 PM, Michael Hipp wrote: On 11/1/2010 11:33 AM, Michael Bayer wrote: OK I think in this case, as in many others, is that subtransactions are not an easy to learn feature, hence it is controlled by a flag that is off by default. ... ... for features that aren't

Re: [sqlalchemy] Subtransactions

2010-11-01 Thread Michael Bayer
On Nov 1, 2010, at 3:12 PM, Michael Bayer wrote: On Nov 1, 2010, at 2:08 PM, Michael Hipp wrote: On 11/1/2010 11:33 AM, Michael Bayer wrote: OK I think in this case, as in many others, is that subtransactions are not an easy to learn feature, hence it is controlled by a flag that is off

Re: [sqlalchemy] Subtransactions

2010-11-01 Thread Michael Hipp
On 11/1/2010 3:12 PM, Michael Bayer wrote: new section: http://www.sqlalchemy.org/docs/orm/session.html#using-subtransactions This section now attempts to explain the full purpose and rationale of the subtransactions feature including an example. Hope it's clear. Thank you, looks

[sqlalchemy] Subtransactions problem

2010-10-14 Thread Juan Antonio Ibáñez
Hello! I am dealing with Turbogears and SQL Alchemy. I need to make one import from a CSV file to a MySQL DB. I need also to controll which rows fails on import. I am working with the next code inside a loop: try: session.begin(subtransactions=True)

Re: [sqlalchemy] Subtransactions problem

2010-10-14 Thread Michael Bayer
On Oct 14, 2010, at 11:40 AM, Juan Antonio Ibáñez wrote: Hello! I am dealing with Turbogears and SQL Alchemy. I need to make one import from a CSV file to a MySQL DB. I need also to controll which rows fails on import. I am working with the next code inside a loop: