Closed GoogleCodeExporter closed 9 years ago
pyodbc never modifies your SQL, so this is a problem finding the right
specification for the Excel driver.
It is *possible* that there is a problem with a Unicode query string, but I
don't think so. I use them quite often. There are some issues open regarding
that, however, which I'll try to address in the next week or so and make a new
release.
Since this really isn't a pyodbc issue, I'm going to close it, but I recommend
you discuss this on the group if you haven't already. Maybe someone already
using Excel will know a trick or two.
Also, I'll try to create a set of unit tests for Excel like I have for some
other data sources, but it is a bit difficult to maintain.
Good luck!
Original comment by mkleehammer
on 24 Aug 2010 at 3:59
Thanks!
Original comment by ammanjjot
on 26 Aug 2010 at 11:58
You should enclose table name in square brackets in the sql query.
for ex:
rs = cursor.execute("select * from [Sheet1$]")
Original comment by omprakas...@gmail.com
on 27 Aug 2010 at 6:14
Thanks, but I already tried the square brackets and get the following error:
Error: ('07002', '[07002] [Microsoft][ODBC Excel Driver] Too few parameters.
Expected 1. (-3010) (SQLExecDirectW)')
Original comment by ammanjjot
on 31 Aug 2010 at 8:32
Can you please post the code for the example you have tried with square
brackets or back quotes. I will check and give you feedback on that.
This is the code that worked for me:
conn = pyodbc.connect("Driver={Microsoft Excel Driver (*.xls)};
Dbq=c:\TestXLS.xls", autocommit=True)
cursor = conn.cursor()
rs = cursor.execute("select * from [Basic Sheet$] where Solution = 'test'")
Original comment by omprakas...@gmail.com
on 1 Sep 2010 at 4:14
Original comment by mkleehammer
on 21 Nov 2010 at 4:43
Original issue reported on code.google.com by
ammanjjot
on 13 Aug 2010 at 2:10