MCPcopy Index your code
hub / github.com/PyMySQL/mysqlclient / executemany

Method executemany

src/MySQLdb/cursors.py:220–251  ·  view source on GitHub ↗

Execute a multi-row query. :param query: query to execute on server :param args: Sequence of sequences or mappings. It is used as parameter. :return: Number of rows affected, if any. This method improves performance on multiple-row INSERT and REPLACE. Othe

(self, query, args)

Source from the content-addressed store, hash-verified

218 return self._mogrify(query, args).decode(self._get_db().encoding)
219
220 def executemany(self, query, args):
221 # type: (str, list) -> int
222 """Execute a multi-row query.
223
224 :param query: query to execute on server
225 :param args: Sequence of sequences or mappings. It is used as parameter.
226 :return: Number of rows affected, if any.
227
228 This method improves performance on multiple-row INSERT and
229 REPLACE. Otherwise it is equivalent to looping over args with
230 execute().
231 """
232 if not args:
233 return
234
235 m = RE_INSERT_VALUES.match(query)
236 if m:
237 q_prefix = m.group(1) % ()
238 q_values = m.group(2).rstrip()
239 q_postfix = m.group(3) or ""
240 assert q_values[0] == "(" and q_values[-1] == ")"
241 return self._do_execute_many(
242 q_prefix,
243 q_values,
244 q_postfix,
245 args,
246 self.max_stmt_length,
247 self._get_db().encoding,
248 )
249
250 self.rowcount = sum(self.execute(query, arg) for arg in args)
251 return self.rowcount
252
253 def _do_execute_many(
254 self, prefix, values, postfix, args, max_stmt_length, encoding

Callers 8

test_executemanyMethod · 0.80
check_data_integrityMethod · 0.80
test_transactionsMethod · 0.80
test_truncationMethod · 0.80
test_executemanyFunction · 0.80
test_binary_prefixFunction · 0.80

Calls 3

_do_execute_manyMethod · 0.95
_get_dbMethod · 0.95
executeMethod · 0.95

Tested by 7

test_executemanyMethod · 0.64
test_transactionsMethod · 0.64
test_truncationMethod · 0.64
test_executemanyFunction · 0.64
test_binary_prefixFunction · 0.64