summaryrefslogtreecommitdiff
path: root/Modules/_sqlite/module.c
diff options
context:
space:
mode:
authorErlend E. Aasland <erlend.aasland@protonmail.com>2022-11-12 23:44:41 +0100
committerGitHub <noreply@github.com>2022-11-12 23:44:41 +0100
commitc95f554a408f76f96c14c006ebe8a0d3d3b40765 (patch)
tree28095c0d6ad6b85f09aeae6028038dc62131e6fd /Modules/_sqlite/module.c
parent99972dc7450f1266e39202012827f4f3c995b0ca (diff)
downloadcpython-git-c95f554a408f76f96c14c006ebe8a0d3d3b40765.tar.gz
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>
Diffstat (limited to 'Modules/_sqlite/module.c')
-rw-r--r--Modules/_sqlite/module.c7
1 files changed, 6 insertions, 1 deletions
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;