Skip to content

Commit c1b8e8a

Browse files
committed
autocommit=None means using server default.
1 parent 9b83342 commit c1b8e8a

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

MySQLdb/connections.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,9 @@ class object, used to create cursors (keyword only)
140140
integer, non-zero enables LOAD LOCAL INFILE; zero disables
141141
142142
autocommit
143+
If False (default), autocommit is disabled.
143144
If True, autocommit is enabled.
145+
If None, autocommit isn't set and server default is used.
144146
145147
There are a number of undocumented, non-standard methods. See the
146148
documentation for the MySQL C API for some hints on what they do.
@@ -227,9 +229,11 @@ def string_decoder(s):
227229
self.encoders[types.StringType] = string_literal
228230
self.encoders[types.UnicodeType] = unicode_literal
229231
self._transactional = self.server_capabilities & CLIENT.TRANSACTIONS
230-
if self._transactional and not kwargs2.pop('autocommit', False):
232+
if self._transactional:
231233
# PEP-249 requires autocommit to be initially off
232-
self.autocommit(False)
234+
autocommit = kwargs2.pop('autocommit', False)
235+
if autocommit is not None:
236+
self.autocommit(bool(True))
233237
self.messages = []
234238

235239
def cursor(self, cursorclass=None):

0 commit comments

Comments
 (0)