def executemany(self, query, args):<EOL>
del self.messages[:]<EOL>if not args:<EOL><INDENT>return<EOL><DEDENT>m = RE_INSERT_VALUES.match(query)<EOL>if m:<EOL><INDENT>q_prefix = m.group(<NUM_LIT:1>) % ()<EOL>q_values = m.group(<NUM_LIT:2>).rstrip()<EOL>q_postfix = m.group(<NUM_LIT:3>) or '<STR_LIT>'<EOL>assert q_values[<NUM_LIT:0>] == '<STR_LIT:(>' and q_values[-<NUM_LIT:1>] == '<STR_LIT:)>'<EOL>return self._do_execute_many(q_prefix, q_values, q_postfix, args,<EOL>self.max_stmt_length,<EOL>self._get_db().encoding)<EOL><DEDENT>self.rowcount = sum(self.execute(query, arg) for arg in args)<EOL>return self.rowcount<EOL>
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. Otherwise it is equivalent to looping over args with
        execute().