From c95f554a408f76f96c14c006ebe8a0d3d3b40765 Mon Sep 17 00:00:00 2001 From: "Erlend E. Aasland" Date: Sat, 12 Nov 2022 23:44:41 +0100 Subject: gh-83638: Add sqlite3.Connection.autocommit for PEP 249 compliant behaviour (#93823) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Introduce the autocommit attribute to Connection and the autocommit parameter to connect() for PEP 249-compliant transaction handling. Co-authored-by: Alex Waygood Co-authored-by: C.A.M. Gerlach Co-authored-by: Géry Ogam --- Modules/_sqlite/module.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'Modules/_sqlite/module.c') diff --git a/Modules/_sqlite/module.c b/Modules/_sqlite/module.c index 707aae160a..6db3d51fd2 100644 --- a/Modules/_sqlite/module.c +++ b/Modules/_sqlite/module.c @@ -46,7 +46,8 @@ module _sqlite3 PyDoc_STRVAR(module_connect_doc, "connect($module, /, database, timeout=5.0, detect_types=0,\n" " isolation_level='', check_same_thread=True,\n" -" factory=ConnectionType, cached_statements=128, uri=False)\n" +" factory=ConnectionType, cached_statements=128, uri=False, *,\n" +" autocommit=sqlite3.LEGACY_TRANSACTION_CONTROL)\n" "--\n" "\n" "Opens a connection to the SQLite database file database.\n" @@ -706,6 +707,10 @@ module_exec(PyObject *module) goto error; } + if (PyModule_AddIntMacro(module, LEGACY_TRANSACTION_CONTROL) < 0) { + goto error; + } + int threadsafety = get_threadsafety(state); if (threadsafety < 0) { goto error; -- cgit v1.2.1