mirror of
https://github.com/python/cpython.git
synced 2025-08-31 05:58:33 +00:00
gh-83638: Add sqlite3.Connection.autocommit for PEP 249 compliant behaviour (#93823)
Introduce the autocommit attribute to Connection and the autocommit parameter to connect() for PEP 249-compliant transaction handling. Co-authored-by: Alex Waygood <Alex.Waygood@Gmail.com> Co-authored-by: C.A.M. Gerlach <CAM.Gerlach@Gerlach.CAM> Co-authored-by: Géry Ogam <gery.ogam@gmail.com>
This commit is contained in:
parent
99972dc745
commit
c95f554a40
14 changed files with 537 additions and 62 deletions
|
@ -855,7 +855,8 @@ _pysqlite_query_execute(pysqlite_Cursor* self, int multiple, PyObject* operation
|
|||
|
||||
/* We start a transaction implicitly before a DML statement.
|
||||
SELECT is the only exception. See #9924. */
|
||||
if (self->connection->isolation_level
|
||||
if (self->connection->autocommit == AUTOCOMMIT_LEGACY
|
||||
&& self->connection->isolation_level
|
||||
&& self->statement->is_dml
|
||||
&& sqlite3_get_autocommit(self->connection->db))
|
||||
{
|
||||
|
@ -1033,7 +1034,9 @@ pysqlite_cursor_executescript_impl(pysqlite_Cursor *self,
|
|||
|
||||
// Commit if needed
|
||||
sqlite3 *db = self->connection->db;
|
||||
if (!sqlite3_get_autocommit(db)) {
|
||||
if (self->connection->autocommit == AUTOCOMMIT_LEGACY
|
||||
&& !sqlite3_get_autocommit(db))
|
||||
{
|
||||
int rc = SQLITE_OK;
|
||||
|
||||
Py_BEGIN_ALLOW_THREADS
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue