Hello, Thanks for the lengthy (!) explanation.
On Jul 13, 1:05 am, Michael Bayer <mike...@zzzcomputing.com> wrote: > Postgres in > particular has operations which, once failed, the transaction is not > allowed to continue: Ouch. I'll have to change my strategy, then (I run unit tests with SQLite but the production backend is PostgreSQL-based). > What SQLAlchemy offers that solves both issues is support of > SAVEPOINT, via begin_nested(). Using begin_nested(), you can frame > an operation that may potentially fail within a transaction, and then > "roll back" to the point before its failure while maintaining the > enclosing transaction. For some reason, calling rollback() or commit() after begin_nested() doesn't work (with SQLite): [...] File "/home/antoine/ftth/XXX/XXX/model/logement.py", line 154, in generer_decharge db_session.commit() File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/orm/scoping.py", line 121, in do return getattr(self.registry(), name)(*args, **kwargs) File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/orm/session.py", line 673, in commit self.transaction.commit() File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/orm/session.py", line 382, in commit t[1].commit() File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/engine/base.py", line 1036, in commit self._do_commit() File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/engine/base.py", line 1071, in _do_commit self.connection._release_savepoint_impl(self._savepoint, self._parent) File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/engine/base.py", line 768, in _release_savepoint_impl self.engine.dialect.do_release_savepoint(self, name) File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/engine/default.py", line 117, in do_release_savepoint connection.execute(expression.ReleaseSavepointClause(name)) File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/engine/base.py", line 824, in execute return Connection.executors[c](self, object, multiparams, params) File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/engine/base.py", line 874, in _execute_clauseelement return self.__execute_context(context) File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/engine/base.py", line 896, in __execute_context self._cursor_execute(context.cursor, context.statement, context.parameters[0], context=context) File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/engine/base.py", line 950, in _cursor_execute self._handle_dbapi_exception(e, statement, parameters, cursor, context) File "/usr/lib/python2.6/site-packages/SQLAlchemy-0.5.4p2-py2.6.egg/ sqlalchemy/engine/base.py", line 931, in _handle_dbapi_exception raise exc.DBAPIError.instance(statement, parameters, e, connection_invalidated=is_disconnect) OperationalError: (OperationalError) no such savepoint: sa_savepoint_1 u'RELEASE SAVEPOINT sa_savepoint_1' [] --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sqlalchemy" group. To post to this group, send email to sqlalchemy@googlegroups.com To unsubscribe from this group, send email to sqlalchemy+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sqlalchemy?hl=en -~----------~----~----~----~------~----~------~--~---