@@ -110,34 +110,6 @@ def __exit__(self, *exc_info):
110
110
del exc_info
111
111
self .close ()
112
112
113
- def _escape_args (self , args , conn ):
114
- encoding = conn .encoding
115
- literal = conn .literal
116
-
117
- def ensure_bytes (x ):
118
- if isinstance (x , str ):
119
- return x .encode (encoding )
120
- elif isinstance (x , tuple ):
121
- return tuple (map (ensure_bytes , x ))
122
- elif isinstance (x , list ):
123
- return list (map (ensure_bytes , x ))
124
- return x
125
-
126
- if isinstance (args , (tuple , list )):
127
- ret = tuple (literal (ensure_bytes (arg )) for arg in args )
128
- elif isinstance (args , dict ):
129
- ret = {
130
- ensure_bytes (key ): literal (ensure_bytes (val ))
131
- for (key , val ) in args .items ()
132
- }
133
- else :
134
- # If it's not a dictionary let's try escaping it anyways.
135
- # Worst case it will throw a Value error
136
- ret = literal (ensure_bytes (args ))
137
-
138
- ensure_bytes = None # break circular reference
139
- return ret
140
-
141
113
def _check_executed (self ):
142
114
if not self ._executed :
143
115
raise ProgrammingError ("execute() first" )
@@ -279,8 +251,6 @@ def executemany(self, query, args):
279
251
def _do_execute_many (
280
252
self , prefix , values , postfix , args , max_stmt_length , encoding
281
253
):
282
- conn = self ._get_db ()
283
- escape = self ._escape_args
284
254
if isinstance (prefix , str ):
285
255
prefix = prefix .encode (encoding )
286
256
if isinstance (values , str ):
@@ -289,11 +259,11 @@ def _do_execute_many(
289
259
postfix = postfix .encode (encoding )
290
260
sql = bytearray (prefix )
291
261
args = iter (args )
292
- v = values % escape ( next (args ), conn )
262
+ v = self . _mogrify ( values , next (args ))
293
263
sql += v
294
264
rows = 0
295
265
for arg in args :
296
- v = values % escape ( arg , conn )
266
+ v = self . _mogrify ( values , arg )
297
267
if len (sql ) + len (v ) + len (postfix ) + 1 > max_stmt_length :
298
268
rows += self .execute (sql + postfix )
299
269
sql = bytearray (prefix )
0 commit comments