| Bugs item #1065008, was opened at 2004-11-12 19:25
Message generated for change (Comment added) made by mhammond
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1065008&group_id=78018
Category: None
Group: None
Status: Open
>Resolution: None
Priority: 5
Submitted By: 江文 (jiangwen365)
Assigned to: Nobody/Anonymous (nobody)
Summary: Contrary to the Doc,ODBC module not accept Connection String
Initial Comment:
It seems that the ODBC module only works with DNS 
names, but not Connection Strings, like:
odbc.odbc(('Provider=Microsoft.Jet.OLEDB.4.0;Data 
Source=c:\aaa.xls;Extended Properties="Excel 
8.0;HDR=Yes;IMEX=1"' ) will fail.
But it IS said to be acceptable in odbc module 
documents.
----------------------------------------------------------------------
>Comment By: Mark Hammond (mhammond)
Date: 2004-11-13 15:15
Message:
Logged In: YES 
user_id=14198
I'm fairly certain that *some* datasource strings work fine
with this module.  Unfortunately, I don't know enough about
this to know where to start.
----------------------------------------------------------------------
Comment By: 江文 (jiangwen365)
Date: 2004-11-13 14:59
Message:
Logged In: YES 
user_id=1147025
Oh, yes, but I think this is not the cause.
I changed the strProcessFolder to be 'c:\FreightAuditTool', 
but it still returned the traceback:
Traceback (most recent call last):
  File "D:/PythonProjects/test.py", line 16, in ?
    a=odbc.odbc(con_str)
dbi.operation-error: [Microsoft][ODBC Driver Manager] Data 
source name not found and no default driver specified in LOGIN
While the ADODB part still correctly printed the ADO recode 
set object just as before:
<win32com.gen_py.Microsoft ActiveX Data Objects 2.5 
Library.Fields instance at 0x17884424>
which shows that the connection string has no problem.
----------------------------------------------------------------------
Comment By: Mark Hammond (mhammond)
Date: 2004-11-13 09:12
Message:
Logged In: YES 
user_id=14198
You have made the same mistake again:
strProcessFolder='c:\FreightAuditTool'
That is an invalid folder name.  What you probably mean is:
strProcessFolder='c:\FreightAuditTool'
or
strProcessFolder=r'c:\FreightAuditTool'
----------------------------------------------------------------------
Comment By: 江文 (jiangwen365)
Date: 2004-11-13 02:07
Message:
Logged In: YES 
user_id=1147025
Below is my code, ODBC module simply failed while it works 
with ADODB by COM:
 
import dbi,odbc
import win32com.client
strProcessFolder='c:\FreightAuditTool'
FileName='ChinaTruckInvoices.xls'
con_str='Provider=Microsoft.Jet.OLEDB.4.0;Data Source=%
s;Extended Properties="Excel 8.0;HDR=Yes;IMEX=1"' %(strProcessFolder+'\'+FileName)
print con_str
sour_conn = win32com.client.gencache.EnsureDispatch
('ADODB.Connection')
sour_conn.Open(con_str)
recordset=sour_conn.Execute('select * from [Invoices$]')[0]
print recordset
a=odbc.odbc(con_str)
and the output was:
Provider=Microsoft.Jet.OLEDB.4.0;Data 
Source=c:\FreightAuditTool\ChinaTruckInvoices.xls;Extended 
Properties="Excel 8.0;HDR=Yes;IMEX=1"
<win32com.gen_py.Microsoft ActiveX Data Objects 2.5 
Library.Fields instance at 0x17884424>
Traceback (most recent call last):
  File "D:/PythonProjects/test.py", line 16, in ?
    a=odbc.odbc(con_str)
dbi.operation-error: [Microsoft][ODBC Driver Manager] Data 
source name not found and no default driver specified in LOGIN
I hope some one could fix the ODBC modue to support 
connection string. It's so easier to use and I found it seems 
run much faster than ADODB with Win32com. Also, It can 
easily be packaged by py2exe, while I found it's really a hard 
nut to crack packaging win32com modules.
Regards
Xiao Zhou
----------------------------------------------------------------------
Comment By: Mark Hammond (mhammond)
Date: 2004-11-12 22:18
Message:
Logged In: YES 
user_id=14198
Are you sure this is not a backslash quoting problem?  As
quoted:
>>> "c:\a"
'c:\x07'
>>> "c:\a"
'c:\a'
>>> 
----------------------------------------------------------------------
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=551954&aid=1065008&group_id=78018
 |