On Apr 24, 2008, at 1:04 PM, Paul Johnston wrote:
>
> Hi,
>
>> Since our system went live we have been getting more & more errors
>> like this: "DBAPIError: (Error) ('HY000', '[HY000] [Microsoft][SQL
>> Native Client]Connection is busy with results for another command
>> (0)') u'SELECT" ...snip valid SQL string...endsnip
>>
>>
> I've seen this error too, in fact some of the unit tests trigger it.
> The
> cause is that a single ODBC connection can only have one query
> active at
> a time, even if you have multiple cursors. I believe this is different
> to most other DBAPI drivers.
>
> I have no idea how to fix this in SQLAlchemy, have thought about it a
> bit without success. A workaround is to recode your app to it fetches
> results right after each query.
we used to have a feature on the Pool called "auto_close_cursors" -
this would track all open cursors at the pool level, and when a
connection is re-checked in would close them all. In reality, this
feature was in most cases just hiding opened cursors that should have
been closed at higher levels, and added a lot of latency at a crucial
point in execution. So in modern SQLAlchemy, cursors are closed
automatically when: 1. the statement is a non-row returning statement
like INSERT, UPDATE, etc. 2. all result rows are exhausted from a
result. (When the ORM is used, result rows are always fully exhausted
unless the "yield_per" Query option is used). So if you are using
straight connection or engine result sets, and are not explicitly
exhausting all rows, call result.close() to explicitly release the
cursor. That will solve the problem.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"sqlalchemy" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---