| Issue 355: | UnicodeDecodeError in cursor.execute on specific column names | |
| 1 person starred this issue and may be notified of changes. | Back to list |
What steps will reproduce the problem?
import pyodbc
db=pyodbc.connect('DSN=Veramtex_tst')
cur=db.cursor()
cur.execute('select cdno from contacts')
<pyodbc.Cursor object at 0x02B8EFA8>
cur.execute("select cdno as 'é' from contacts")
Traceback (innermost last):
File "<stdin>", line 1, in <module>
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe9 in position 0: unexpected end of data
cur.execute("select 'é' as e from contacts")
<pyodbc.Cursor object at 0x02B8EFA8>
What is the expected output? What do you see instead?
The second query should work the same way as the first one. Instead, I got a UnicodeDecodeError As the third query works well, I strongly suspect that pyodbc has problems on non ASCII column names.
What version of the product are you using? On what operating system?
Python 3.3.3
pyodbc 3.0.7
dabatabase: MySQL 5.5.34
Please provide any additional information below.
Jan 20, 2014
#1
marc.van...@gmail.com
Feb 2, 2014
(No comment was entered for this change.)
Status:
Investigating
Feb 28, 2014
I have the same problem: conexionDSNnavision = pyodbc.connect(DSN=config.DSNnavision, autocommit=True, ansi=True, readonly=True, unicode_results=True) cursorDSNnavision = conexionDSNnavision.cursor() query = "SELECT Nº,Nombre FROM Cliente cursorDSNnavision.execute(query) Error: cursorDSNnavision.execute(query) UnicodeDecodeError: 'utf-8' codec can't decode byte 0xba in position 1: invalid start byte but I do this: conexionDSNnavision = pyodbc.connect(DSN=config.DSNnavision, autocommit=True, ansi=True, readonly=True, unicode_results=True) cursorDSNnavision = conexionDSNnavision.cursor() query = "SELECT Nº FROM Cliente cursorDSNnavision.execute(query) works perfectly, what's happening?
Mar 3, 2014
Workaround:
Executoing the following instruction:
db.execute("SET @@character_set_results = 'latin1'")
before issuing the SELECT statement,
everything works well.
Question now is why is it necessary to do that and how can I know which character set to use?
|