diff --git a/pandaserver/taskbuffer/WrappedCursor.py b/pandaserver/taskbuffer/WrappedCursor.py index e1a0323d..7a98183f 100644 --- a/pandaserver/taskbuffer/WrappedCursor.py +++ b/pandaserver/taskbuffer/WrappedCursor.py @@ -159,6 +159,13 @@ def __init__(self, connection): self.dump = False # SQL conversion map self.sql_conv_map = {} + # executemany + if self.backend == "postgres": + from psycopg2.extras import execute_batch + + self.alt_executemany = execute_batch + else: + self.alt_executemany = None # __iter__ def __iter__(self): @@ -412,11 +419,10 @@ def executemany(self, sql, params): if sql is None: sql = self.statement sql = self.change_schema(sql) - if self.backend == "oracle": - self.cur.executemany(sql, params) + if self.alt_executemany: + self.alt_executemany(self.cur, sql, params) else: - for paramsItem in params: - self.execute(sql, paramsItem) + self.cur.executemany(sql, params) # get_description @property