PiRSquared17 / pyodbc

Automatically exported from code.google.com/p/pyodbc
Other
0 stars 0 forks source link

connect() trying to set SQL_ATTR_AUTOCOMMIT although not requested #162

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
I encountered this bug while trying to work with the ODBC Lotus Notes Driver.

Even though according to [1] autocommit defaults to False and even though I 
tried manually forcing it not to request autocommitting by explicitly setting 
autocommmit=False it appears that pyodbc still tries to set it.

The error is:
Error: ('S1C00', '[S1C00] [Lotus][ODBC Lotus Notes]Driver not capable (23370) 
(SQLSetConnnectAttr(SQL_ATTR_AUTOCOMMIT))')

First I thought it might be a bug in the ODBC Lotus Notes driver, but I tested 
the driver with PHP's ODBC functions and everything works fine there.

What version of the product are you using? On what operating system?
pyodbc 2.1.8 with Python 2.7.1 on Windows XP SP3

[1] http://code.google.com/p/pyodbc/wiki/Module#connect

Original issue reported on code.google.com by Wurm...@gmail.com on 10 Mar 2011 at 9:57

GoogleCodeExporter commented 9 years ago
ODBC defaults to autocommit *on*, so if you want to disable pyodbc from making 
this call to the driver then explicitly set autocommit=True

Original comment by lukedell...@gmail.com on 16 Mar 2011 at 5:58

GoogleCodeExporter commented 9 years ago
Thanks, that did it.

I find it relatively unintuitive to have to specify autocommit=True to actually 
turn off autocommitting. Could the documentation be updated?

Original comment by Wurm...@gmail.com on 16 Mar 2011 at 2:44

GoogleCodeExporter commented 9 years ago
Oh no autocommit=True turns *on* autocommitting as you would hope.

The key to understanding your initial problem is that ODBC defaults to 
autocommit enabled, whereas pyodbc must default to autocommit disabled (by 
decree of the Python Database API, PEP 249).  This means that by default pyodbc 
must explicitly call the ODBC API to disable autocommit.  It is this call which 
is failing for your Lotus Notes driver.  Specifying autocommit=True means that 
pyodbc can skip making this call.

Original comment by lukedell...@gmail.com on 21 Mar 2011 at 10:59

GoogleCodeExporter commented 9 years ago
Well, I guess this problem is then very specific to my case. I suppose there 
are not many SQL drivers out there not supporting SQL_ATTR_AUTOCOMMIT.

Probably violates the ODBC standard, but hey, the driver is mapping a non-SQL 
database format (Notes Storage Format, NSF) to SQL.

Original comment by Wurm...@gmail.com on 21 Mar 2011 at 11:47

GoogleCodeExporter commented 9 years ago
Luke, thanks again!

Original comment by mkleehammer on 27 Dec 2011 at 1:05