Open GoogleCodeExporter opened 8 years ago
Could you attach a test script? I've pasted your example into emacs and
notepad and I get a Python syntax error, so clearly I'm doing something wrong.
I've tried Python 2.6 and 2.7, 32 and 64-bit.
Thanks...
Original comment by mkleehammer
on 26 Aug 2010 at 10:23
Original comment by mkleehammer
on 21 Nov 2010 at 6:07
Hi
I had the same issue if need a unicode string to connect:
Systems tested: Windows 7, windows XP and Windows2000 sp4
Python version: 2.7
pyodbc version: 2.1.8
1. Created two copies of 1 database.
The first uses a pure ascii password
the second uses a passwor wich contains a unicode character "yyy\xe9yyyy"
2. Create ODBC datasources for both databases an test they works properly
3. Retrive the DSN info from the system registry using a python script.
4. link the DSN info creating proper DSN strings DSN1 and DSN2
the only difference is DSN2 contains the character \xe9 (in the registered password)
DSN1 = "DSN=Db1CopyDSNName;PWD=Db1password"
DSN2 = u"DSN=Db2CopyDSNName;PWD=Db2password" #so it contains 1 unicode char.
5. create connections:
>>> cnn1 = pyodbc.connect(DSN1) #SUCCESS
>>> cnn2 = pyodbc.connect(DSN2) #SYSTEM EXCEPTION
6. The exception as was printed by IDLE:
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
cnn = pyodbc.connect('DSN=adsntodb1PwdUtf;PWD=Némesis')
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 25:
ordinal not in range(128)
SUGESTION: I've got the same exception when reading from databases wich
contains utf strings and manipulate the outputs. I've solved it creating a
simple script to ensure all the strings, I use, are unicode. I supouse the
codec exception raises when pyodbc links the dsn to perform operations (perhaps
before passig the info to your C libraries)
Original comment by luisguil...@gmail.com
on 18 Jul 2011 at 7:04
Original issue reported on code.google.com by
mbu...@gmail.com
on 12 Jul 2010 at 12:09