I am using pyodbc on python 2.6 to connect to Microsoft SQL Server 2005. I open the connection, create a pair of cursors:
c1 = connection.cursor() c2 = connection.cursor()
and then run the query for the first cursor.
c1.execute("select * from foo")
Now I run a query on the second cursor:
c2.execute("select * from bar")
... and I get an error: "The connection is busy with the results for another hstmt."
After doing c1.fetchall() or c1.close() I can use c2.
My question is: why am I even allowed to create multiple cursors in the connection, if I am allowed to use only one at a time, and the same can always be reused? And, if I want to run a query for each row of the results of another query, for example:
for x in c1.execute(...): for y in c2.execute(...):
Do I really need to create multiple connections to the same database?
python sql-server pyodbc
Josh
source share