Skip to content

Commit

Permalink
executemany for postgres
Browse files Browse the repository at this point in the history
  • Loading branch information
tmaeno committed Nov 15, 2024
1 parent 02abe5d commit 0a927ae
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions pandaserver/taskbuffer/WrappedCursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0a927ae

Please sign in to comment.