Example #1
0
 def executemany(self, query, args):
     del self.messages[:]
     db = self._get_db()
     if not args:
         return
     charset = db.character_set_name()
     if isinstance(query, unicode):
         query = query.encode(charset)
     m = insert_values.search(query)
     if not m:
         r = 0
         for a in args:
             time.sleep(self.thread_delay)  # for perf
             r = r + self.execute(query, a)
         return r
     p = m.start(1)
     e = m.end(1)
     qv = m.group(1)
     try:
         q = [qv % db.literal(a) for a in args]
     except TypeError, msg:
         if msg.args[0] in ("not enough arguments for format string", "not all arguments converted"):
             self.errorhandler(self, ProgrammingError, msg.args[0])
         else:
             self.errorhandler(self, TypeError, msg)