ipython-sql: mssql+pyodbc Error: Connection is busy with results for another command

Hello,

this project seems really useful, but sadly, I can’t get it to work with MSSql over odbc. SqlAlchemy itself works fine with this setup, but I cannot execute a single query with ipython-sql. Maybe ipython-sql does a query without fetching the results? ODBC+MSql does not like that.

%%sql mssql+pyodbc://@myDSN SELECT TOP 100 * FROM SomeDB.dbo.tbl_sometable;

(pyodbc.Error) ('HY000', '[HY000] [Microsoft][SQL Server Native Client 11.0]Connection is busy with results for another command (0) (SQLExecDirectW)') [SQL: 'commit']

  • ablepharus

About this issue

Most upvoted comments

In the connection string, try setting MARS_Connection=Yes

MARS_Connection=Yes

is case sensitive.

I got this error for a mistake on my part that was not related to the error text. I was attempting to query a table with a cursor that was assigned to another database. In other words, the table was not in the database I was querying. This mistake resulted in the above error. Hope this helps someone else!