MCPcopy
hub / github.com/PyMySQL/PyMySQL / _do_execute_many

Method _do_execute_many

pymysql/cursors.py:200–228  ·  view source on GitHub ↗
(
        self, prefix, values, postfix, args, max_stmt_length, encoding
    )

Source from the content-addressed store, hash-verified

198 return self.rowcount
199
200 def _do_execute_many(
201 self, prefix, values, postfix, args, max_stmt_length, encoding
202 ):
203 conn = self._get_db()
204 escape = self._escape_args
205 if isinstance(prefix, str):
206 prefix = prefix.encode(encoding)
207 if isinstance(postfix, str):
208 postfix = postfix.encode(encoding)
209 sql = bytearray(prefix)
210 args = iter(args)
211 v = values % escape(next(args), conn)
212 if isinstance(v, str):
213 v = v.encode(encoding, "surrogateescape")
214 sql += v
215 rows = 0
216 for arg in args:
217 v = values % escape(arg, conn)
218 if isinstance(v, str):
219 v = v.encode(encoding, "surrogateescape")
220 if len(sql) + len(v) + len(postfix) + 1 > max_stmt_length:
221 rows += self.execute(sql + postfix)
222 sql = bytearray(prefix)
223 else:
224 sql += b","
225 sql += v
226 rows += self.execute(sql + postfix)
227 self.rowcount = rows
228 return rows
229
230 def callproc(self, procname, args=()):
231 """Execute stored procedure procname with args.

Callers 1

executemanyMethod · 0.95

Calls 2

_get_dbMethod · 0.95
executeMethod · 0.95

Tested by

no test coverage detected