File tree 2 files changed +37
-2
lines changed
2 files changed +37
-2
lines changed Original file line number Diff line number Diff line change @@ -110,6 +110,10 @@ class object, used to create cursors (keyword only)
110
110
:param int client_flag:
111
111
flags to use or 0 (see MySQL docs or constants/CLIENTS.py)
112
112
113
+ :param bool multi_statements:
114
+ If True, enable multi statements for clients >= 4.1.
115
+ Defaults to True.
116
+
113
117
:param str ssl_mode:
114
118
specify the security settings for connection to the server;
115
119
see the MySQL documentation for more details
@@ -169,11 +173,16 @@ class object, used to create cursors (keyword only)
169
173
self ._binary_prefix = kwargs2 .pop ("binary_prefix" , False )
170
174
171
175
client_flag = kwargs .get ("client_flag" , 0 )
176
+
172
177
client_version = tuple (
173
178
[numeric_part (n ) for n in _mysql .get_client_info ().split ("." )[:2 ]]
174
179
)
175
- if client_version >= (4 , 1 ):
176
- client_flag |= CLIENT .MULTI_STATEMENTS
180
+
181
+ multi_statements = kwargs2 .pop ("multi_statements" , True )
182
+ if multi_statements :
183
+ if client_version >= (4 , 1 ):
184
+ client_flag |= CLIENT .MULTI_STATEMENTS
185
+
177
186
if client_version >= (5 , 0 ):
178
187
client_flag |= CLIENT .MULTI_RESULTS
179
188
Original file line number Diff line number Diff line change
1
+ import pytest
2
+
3
+ from MySQLdb ._exceptions import ProgrammingError
4
+
5
+ from configdb import connection_factory
6
+
7
+
8
+ def test_multi_statements_default_true ():
9
+ conn = connection_factory ()
10
+ cursor = conn .cursor ()
11
+
12
+ cursor .execute ("select 17; select 2" )
13
+ rows = cursor .fetchall ()
14
+ assert rows == ((17 ,),)
15
+
16
+
17
+ def test_multi_statements_false ():
18
+ conn = connection_factory (multi_statements = False )
19
+ cursor = conn .cursor ()
20
+
21
+ with pytest .raises (ProgrammingError ):
22
+ cursor .execute ("select 17; select 2" )
23
+
24
+ cursor .execute ("select 17" )
25
+ rows = cursor .fetchall ()
26
+ assert rows == ((17 ,),)
You can’t perform that action at this time.
0 commit comments