Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions dataset/database.py
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,8 @@ def begin(self):
"""
if not hasattr(self.local, "tx"):
self.local.tx = []
if self.executable.in_transaction():
self.executable.commit()
self.local.tx.append(self.executable.begin())

def commit(self):
Expand Down
5 changes: 5 additions & 0 deletions dataset/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,11 @@ def insert(self, row, ensure=None, types=None):
"""
row = self._sync_columns(row, ensure, types=types)
res = self.db.executable.execute(self.table.insert(), row)
# SQLAlchemy 2.0.0b1 removes auto commit
if hasattr(self.db.local, "tx") and self.db.local.tx:
pass
else:
self.db.executable.commit()
if len(res.inserted_primary_key) > 0:
return res.inserted_primary_key[0]
return True
Expand Down