Look at this code:
<code>import pyodbc
cnxn = pyodbc.connect(connection_string)
cursor = cnxn.cursor()
cursor.execute(query)
cnxn.commit()
</code>
<code>import pyodbc
cnxn = pyodbc.connect(connection_string)
cursor = cnxn.cursor()
cursor.execute(query)
cnxn.commit()
</code>
import pyodbc
cnxn = pyodbc.connect(connection_string)
cursor = cnxn.cursor()
cursor.execute(query)
cnxn.commit()
Usually this code works fine. But there are certain querys which take an infinite time to be executed. This is not a python problem. When I execute them using SQL Server Management Studio I have the same behavior. But there I have the possibility to cancel the query when I’m sick of waiting. I’m looking for an analogue possibility in python. Can I tell python somehow to try it for maybe 10 minutes and cancel then? How do I do taht?