You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
asyncdefexecute_many(self, queries: typing.List[ClauseElement]) ->None:
assertself._connectionisnotNone, "Connection is not acquired"cursor=awaitself._connection.cursor()
try:
forsingle_queryinqueries:
single_query, args, context=self._compile(single_query)
awaitcursor.execute(single_query, args)
finally:
awaitcursor.close()
execute single sql many times?
aiomysql sames work better
asyncdefexecutemany(self, query, args):
"""Execute the given operation multiple times The executemany() method will execute the operation iterating over the list of parameters in seq_params. Example: Inserting 3 new employees and their phone number data = [ ('Jane','555-001'), ('Joe', '555-001'), ('John', '555-003') ] stmt = "INSERT INTO employees (name, phone) VALUES ('%s','%s')" await cursor.executemany(stmt, data) INSERT or REPLACE statements are optimized by batching the data, that is using the MySQL multiple rows syntax. :param query: `str`, sql statement :param args: ``tuple`` or ``list`` of arguments for sql query """ifnotargs:
returnifself._echo:
logger.info("CALL %s", query)
logger.info("%r", args)
m=RE_INSERT_VALUES.match(query)
ifm:
q_prefix=m.group(1)
q_values=m.group(2).rstrip()
q_postfix=m.group(3) or''assertq_values[0] =='('andq_values[-1] ==')'return (awaitself._do_execute_many(
q_prefix, q_values, q_postfix, args, self.max_stmt_length,
self._get_db().encoding))
else:
rows=0forarginargs:
awaitself.execute(query, arg)
rows+=self._rowcountself._rowcount=rowsreturnself._rowcount
The text was updated successfully, but these errors were encountered:
execute single sql many times?
aiomysql sames work better
The text was updated successfully, but these errors were encountered: