mxODBC windows and cursors

damien_morton at my-deja.com damien_morton at my-deja.com
Sat Oct 16 00:04:24 EDT 1999


Hmm, yet another case of 'engage search engine before opening mouth'

I seem to have solved the problem.

By default the MS ODBC driver operates with client side cursors, which
dont support multiple cursors per connection. The following
ODBC options are the defaults which imply client-side cursors:

SQL_CONCURRENCY = SQL_CONCUR_READ_ONLY
SQL_CURSOR_TYPE = SQL_CURSOR_FORWARD_ONLY
SQL_ROWSET_SIZE = 1

Change any or all of these options to something else, and the driver
switches over to using server-side cursors, of which many are allowed
per connection.

See this MSKB article for more info:
http://support.microsoft.com/support/kb/articles/q140/8/96.asp



In article <7u8nsf$icq$1 at nnrp1.deja.com>,
  damien_morton at my-deja.com wrote:
> 	I have been using the mxODBC library in a win32 environment,
> and Ive struck a small problem. Perhaps someone can help. Here is a
> snippet of code:
>
> import ODBC.Windows
> import time, random
>
> ODBC = ODBC.Windows
> SQL = ODBC.SQL
>
> if __name__ == '__main__':
>     db = ODBC.Connect('Test','sa','')
>     db.setconnectoption(SQL.ACCESS_MODE, SQL.MODE_READ_ONLY)
>     c = db.cursor()
>     c.execute("select * from usermail where email_host='AOL.COM'")
>     d = db.cursor()
>     d.execute("select * from usermail where email_host='HOTMAIL.COM'")
>     print c.fetchone()
>     print d.fetchone()
>
> The result of executing this code is listed below:
> >>> OperationalError: ('S1000', 0, '[Microsoft][ODBC SQL Server
Driver]
> Connection is busy with results for another hstmt', 3205)
>
> This seems to indicate to me that I can have only one active cursor
per
> connection. Is this necessarily true? Is there some way around this
> limitation, or will I need to maintain a connection for each cursor?
> (my tests indicate that each connection is about 600K, whereas each
> cursor is about 3K)
>
> Sent via Deja.com http://www.deja.com/
> Before you buy.
>


Sent via Deja.com http://www.deja.com/
Before you buy.




More information about the Python-list mailing list