tanrj / pyodbc

Automatically exported from code.google.com/p/pyodbc
MIT No Attribution
0 stars 0 forks source link

connection to excel fle using pyodbc fails #34

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. set up an Excel file as a SystemDSN using Microsoft Excel Driver
2. try to connect using pyodbc.connect('DSN=<source>')
3.

What is the expected output? What do you see instead?
pyodbc.Error:('HYC00','[HYC00][Microsoft][ODBC Excel Driver]Optional 
feature not implemented (106) (SQLSetConnectAttr(SQL_ATTR_AUTOCOMMIT))')

What version of the product are you using? On what operating system?
pyodbc 2.1.2, Python 2.5.1, Excel 2002, Windows XP

Please provide any additional information below.

I get the same result using autocommit=False in the connection string, and 
using a dsn-less connection string for the same file

Original issue reported on code.google.com by chris.le...@googlemail.com on 12 Feb 2009 at 5:01

GoogleCodeExporter commented 8 years ago
You need to use autocommit=True, actually.

ODBC drivers default to autocommit, but the Python DB API specification 
requires it
to be turned off.  So the first thing pyodbc does is turn *off* autocommit -- 
and
this is what the Excel driver does not support.  If you set the flag to True, 
pyodbc
sees there is nothing to do (the driver is already in autocommit mode).

I'll write something about this in a couple of the Wiki pages.

Original comment by mkleehammer on 12 Feb 2009 at 5:16

GoogleCodeExporter commented 8 years ago
Thanks for the quick response. When I use pyodbc.connect
('DSN=<source>;autocommit=True') I get exactly the same error. Am I missing 
something?

Original comment by chris.le...@googlemail.com on 12 Feb 2009 at 5:24

GoogleCodeExporter commented 8 years ago
The autocommit is not part of the connection string, but is a separate keyword:

cnxn = pyodbc.connect('DSN=<source>', autocommit=True)

Original comment by mkleehammer on 12 Feb 2009 at 5:36

GoogleCodeExporter commented 8 years ago

Original comment by mkleehammer on 9 Mar 2009 at 10:19

GoogleCodeExporter commented 8 years ago

Original comment by mkleehammer on 21 Nov 2010 at 4:43