MCPcopy Index your code
hub / github.com/RustPython/RustPython / set_autocommit

Method set_autocommit

crates/stdlib/src/_sqlite3.rs:1527–1553  ·  view source on GitHub ↗
(&self, val: PyObjectRef, vm: &VirtualMachine)

Source from the content-addressed store, hash-verified

1525 }
1526 #[pygetset(setter)]
1527 fn set_autocommit(&self, val: PyObjectRef, vm: &VirtualMachine) -> PyResult<()> {
1528 let mode = AutocommitMode::try_from_borrowed_object(vm, &val)?;
1529 let db = self.db_lock(vm)?;
1530
1531 // Handle transaction state based on mode change
1532 match mode {
1533 AutocommitMode::Enabled => {
1534 // If there's a pending transaction, commit it
1535 if !db.is_autocommit() {
1536 db._exec(b"COMMIT", vm)?;
1537 }
1538 }
1539 AutocommitMode::Disabled => {
1540 // If not in a transaction, begin one
1541 if db.is_autocommit() {
1542 db._exec(b"BEGIN", vm)?;
1543 }
1544 }
1545 AutocommitMode::Legacy => {
1546 // Legacy mode doesn't change transaction state
1547 }
1548 }
1549
1550 drop(db);
1551 *self.autocommit.lock() = mode;
1552 Ok(())
1553 }
1554
1555 #[pygetset]
1556 fn text_factory(&self) -> PyObjectRef {

Callers

nothing calls this directly

Calls 4

db_lockMethod · 0.80
is_autocommitMethod · 0.80
_execMethod · 0.45
lockMethod · 0.45

Tested by

no test coverage detected