Following SQLAchemy's documentation, savepoint with SQLite is supported (excluding some minro issues with the pysqlite driver where a workaround is avaible).
When trying to use SAVEPOINT with SQLite, the following error is raised:
Traceback (most recent call last):
File "/lib/python3.7/site-packages/transaction/_transaction.py", line 631, in __init__
savepoint = datamanager.savepoint
File "/lib/python3.7/site-packages/zope/sqlalchemy/datamanager.py", line 155, in savepoint
raise AttributeError("savepoint")
AttributeError: savepoint
This is due because SQLite is explicitly declared as not supported:
|
NO_SAVEPOINT_SUPPORT = {"sqlite"} |
|
if set( |
|
engine.url.drivername |
|
for engine in self.session.transaction._connections.keys() |
|
if isinstance(engine, Engine) |
|
).intersection(NO_SAVEPOINT_SUPPORT): |
|
raise AttributeError("savepoint") |
However, if I remove sqlite from the set, my transaction is acting as expected:
[2020-03-30 21:01:12 - INFO/sqlalchemy.engine.base.Engine:711] BEGIN (implicit)
[2020-03-30 21:01:12 - INFO/sqlalchemy.engine.base.Engine:1205] SELECT xxx
[2020-03-30 21:01:12 - INFO/sqlalchemy.engine.base.Engine:1210] ()
[2020-03-30 21:01:12 - INFO/sqlalchemy.engine.base.Engine:1205] SAVEPOINT sa_savepoint_1
[2020-03-30 21:01:12 - INFO/sqlalchemy.engine.base.Engine:1210] ()
[2020-03-30 21:01:12 - INFO/sqlalchemy.engine.base.Engine:1205] INSERT INTO xxx
[2020-03-30 21:01:12 - INFO/sqlalchemy.engine.base.Engine:1210] ()
[2020-03-30 21:01:12 - INFO/sqlalchemy.engine.base.Engine:1205] ROLLBACK TO SAVEPOINT sa_savepoint_1
[2020-03-30 21:01:12 - INFO/sqlalchemy.engine.base.Engine:1210] ()
[2020-03-30 21:01:12 - INFO/sqlalchemy.engine.base.Engine:1205] SELECT xxx
My environment:
SQLAlchemy==1.3.15
transaction==3.0.0
zope.sqlalchemy==1.3
Following SQLAchemy's documentation, savepoint with SQLite is supported (excluding some minro issues with the pysqlite driver where a workaround is avaible).
When trying to use SAVEPOINT with SQLite, the following error is raised:
This is due because SQLite is explicitly declared as not supported:
zope.sqlalchemy/src/zope/sqlalchemy/datamanager.py
Line 59 in ae4745c
zope.sqlalchemy/src/zope/sqlalchemy/datamanager.py
Lines 150 to 155 in ae4745c
However, if I remove
sqlitefrom the set, my transaction is acting as expected:My environment: