ascii decode problem on execute
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
oursql |
New
|
Undecided
|
Unassigned |
Bug Description
When inserting data into a test Mysql db, I ran into the following issue:
File "C:\development
db.
File "C:\development
self.
File "C:\development
rec[
ner_Attention_
File "C:\development
man
instance = self.session.
p_code, country, attn_line))
File "C:\Python27\
return self._load_
File "C:\Python27\
return q.one()
File "C:\Python27\
ret = list(self)
File "C:\Python27\
return self._execute_
File "C:\Python27\
ances
result = conn.execute(
File "C:\Python27\
params)
File "C:\Python27\
element
compiled_sql, distilled_params
File "C:\Python27\
t
context)
File "C:\Python27\
ute
cursor.
File "cursor.pyx", line 122, in oursql.
File "statement.pyx", line 318, in oursql.
UnicodeDecodeError: 'ascii' codec can't decode byte 0xe9 in position 13: ordinal not in range(1
28)
I'm using Python 2.7.2, Sqlalchemy 7.8, and oursql 9.3 on a Win 7 64bit system. I'm reading in a data file in a simple for loop, doing no encoding to the data. I convert each line into a dictionary, then create a new object with the sqlalchemy orm. It converts that object into an insert statement for the oursql library, which fails with this encoding issue when I have non-ascii elements in my data.
Line 318: http://
Looking at the source, it seems that the cursor just assumes that it will receive unicode objects, not strings. Since this check is inside of the use_unicode if statement, disabling that option avoids the problem. However, data is lost in this case.
This answer on SO, http://
Can the documentation be updated to reflect that use_unicode=0 may cause data loss, and that use_unicode=1 expects a unicode object be passed in, not a string?