sw6 - KTBFFH
sw6 - KTBFFH

Reputation: 207

pyodbc locks tables and takes too long to run

I have a python script to download files from an SFTP site to a local folder and then run a stored procedure using the downloaded file. The first aspect runs fine. But then the execution of the stored procedure causes a lock on other tables on the SQL server - returns "Timeout expired" error. The procedure has been running for an hour and half.

This is the syntax I used for the execution of the stored procedure in case anybody was wondering:

conn = pyodbc.connect('DRIVER={SQLServer};SERVER=localhost;DATABASE=Db;UID=myid;PWD=mypwd')
cursor = conn.cursor()

cursor.execute("""exec SP_Upsert_Y ?""",sfile)
cursor.commit()

Upvotes: 1

Views: 3226

Answers (1)

pirikitao
pirikitao

Reputation: 65

i had the same problemn and y solved add the parameter autocommit=True to connection string

Upvotes: 1

Related Questions