From 2123858770e1305358d46fe12c674424aab9b139 Mon Sep 17 00:00:00 2001 From: Pekka Enberg Date: Wed, 25 Jun 2025 18:14:01 +0300 Subject: [PATCH] bindings/python: Add Connection.rollback() --- bindings/python/src/lib.rs | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/bindings/python/src/lib.rs b/bindings/python/src/lib.rs index 234ff7219..ffb88a63a 100644 --- a/bindings/python/src/lib.rs +++ b/bindings/python/src/lib.rs @@ -263,9 +263,16 @@ impl Connection { } pub fn rollback(&self) -> PyResult<()> { - Err(PyErr::new::( - "Transactions are not supported in this version", - )) + if !self.conn.get_auto_commit() { + self.conn.execute("COMMIT").map_err(|e| { + PyErr::new::(format!("Failed to commit: {:?}", e)) + })?; + + self.conn.execute("BEGIN").map_err(|e| { + PyErr::new::(format!("Failed to commit: {:?}", e)) + })?; + } + Ok(()) } fn __enter__(&self) -> PyResult {