mirror of
https://github.com/aljazceru/turso.git
synced 2026-01-05 09:14:24 +01:00
bindings/python: Start transaction implicitly in execute()
We need to start transaction implicitly in execute() for DML statements to make sure first transaction is actually started. Fixes #2002
This commit is contained in:
@@ -93,6 +93,15 @@ impl Cursor {
|
||||
Ok::<(), anyhow::Error>(())
|
||||
})?;
|
||||
|
||||
if stmt_is_dml && self.conn.conn.get_auto_commit() {
|
||||
self.conn.conn.execute("BEGIN").map_err(|e| {
|
||||
PyErr::new::<OperationalError, _>(format!(
|
||||
"Failed to start transaction after DDL: {:?}",
|
||||
e
|
||||
))
|
||||
})?;
|
||||
}
|
||||
|
||||
// For DDL and DML statements,
|
||||
// we need to execute the statement immediately
|
||||
if stmt_is_ddl || stmt_is_dml || stmt_is_tx {
|
||||
|
||||
Reference in New Issue
Block a user