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

Method set_isolation_level

crates/stdlib/src/_sqlite3.rs:1490–1516  ·  view source on GitHub ↗
(
            &self,
            value: PySetterValue<Option<PyStrRef>>,
            vm: &VirtualMachine,
        )

Source from the content-addressed store, hash-verified

1488 }
1489 #[pygetset(setter)]
1490 fn set_isolation_level(
1491 &self,
1492 value: PySetterValue<Option<PyStrRef>>,
1493 vm: &VirtualMachine,
1494 ) -> PyResult<()> {
1495 match value {
1496 PySetterValue::Assign(value) => {
1497 if let Some(val_str) = &value {
1498 begin_statement_ptr_from_isolation_level(val_str, vm)?;
1499 }
1500
1501 // If setting isolation_level to None (auto-commit mode), commit any pending transaction
1502 if value.is_none() {
1503 let db = self.db_lock(vm)?;
1504 if !db.is_autocommit() {
1505 // Keep the lock and call implicit_commit directly to avoid race conditions
1506 db.implicit_commit(vm)?;
1507 }
1508 }
1509 let _ = unsafe { self.isolation_level.swap(value) };
1510 Ok(())
1511 }
1512 PySetterValue::Delete => {
1513 Err(vm.new_attribute_error("'isolation_level' attribute cannot be deleted"))
1514 }
1515 }
1516 }
1517
1518 #[pygetset]
1519 fn autocommit(&self, vm: &VirtualMachine) -> PyObjectRef {

Callers

nothing calls this directly

Calls 7

db_lockMethod · 0.80
is_autocommitMethod · 0.80
implicit_commitMethod · 0.80
ErrClass · 0.50
is_noneMethod · 0.45
swapMethod · 0.45

Tested by

no test coverage detected