is there way to do bulk update using pyodbc using executemany

Viewed 563

I am trying to do bulk update and bulk insert of 120 rows in to SQL server using pyodbc using below code

INSERT is taking around 2 sec where as update is taking 80 seconds. Is there a better way to do bulk update? please guide

conn = pyodbc.connect(f'DRIVER={cfg.SQL_DRIVER};SERVER={cfg.SQL_SERVER};PORT=. 
{cfg.SQL_PORT};DATABASE={cfg.SQL_DATABASE_NAME};UID={cfg.SQL_USERNAME};PWD=. 
{cfg.SQL_PASSWORD.}')
cursor = conn.cursor()      
params = [tuple(x) for x in data.values]
cursor.fast_executemany = True
cursor.executemany(self.query, params)
conn.commit()
conn.close()  
0 Answers
Related