I have tried using 'SAVEPOINT' transactions (via 'session.begin_nested') with a 'SQLite' database connection, but got an exception when a 'session.add()', triggered an integrity error, nstead of the expected 'ROLLBACK TO SAVEPOINT':
The logged statements are:
BEGIN (implicit)
SAVEPOINT sa_savepoint_1
()
INSERT INTO table (col_id, col_a, col_b, col_c) VALUE (?, ?, ?, ?)
(1, None, None, None)
ROLLBACK TO SAVEPOINT sa_savepoint_1
()
ROLLBACK TO SAVEPOINT sa_savepoint_1
()
which triggers:
OperationalError: (OperationalError) no such savepoint: sa_savepoint_1 u'ROLLBACK TO SAVEPOINT sa_savepoint_1' ()
(I can attach the whole traceback if necessary).
It seems that the error is triggered because the 'ROLLBACK TO SAVEPOINT' is executed twice.
I am aware that SAVEPOINT support is relatively recent in SQLite and that transaction isolation levels in SQLite are also a rather intricate affair.
Thanks in advance for any feedback about this issue.
--Pedro.