Bugs item #1690105, was opened at 2007-03-28 23:10
Message generated for change (Comment added) made by phd
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1690105&group_id=74338
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: MySQL
Group: None
>Status: Closed
>Resolution: Fixed
Priority: 5
Private: No
Submitted By: Mirinde Fekus (junas)
>Assigned to: Oleg Broytmann (phd)
Summary: UnicodeEncodeError: 'latin-1' codec can't encode characters
Initial Comment:
I have this
http://pylonshq.com/pasties/198
after upgrading mysqldb to 1.2.2 from 1.2.1 when selecting by value that contains non-latin characters:
res = list(model.Tag.selectBy(tag = tag))
the connection string is
sqlobject.dburi = mysql://****:****@localhost/pyneohuman?sqlobject_encoding=utf-8&charset=utf8 in development.ini
so it's not latin-1...
any ideas?
----------------------------------------------------------------------
>Comment By: Oleg Broytmann (phd)
Date: 2007-12-26 14:50
Message:
Logged In: YES
user_id=4799
Originator: NO
The patch you are proposing here has been applied in the repository. Will
be in 0.7.10, 0.8.7 and 0.9.3 when they will be released.
----------------------------------------------------------------------
Comment By: Viktor Ferenczi (complex)
Date: 2007-08-26 20:40
Message:
Logged In: YES
user_id=142612
Originator: NO
My config: Python 2.5.1, SQLObject 0.9.1, MySQL 4.1.11,
MySQL-python-1.2.2
DB with InnoDB tables, utf8_general_ci everywhere.
SET NAMES utf8 issued as first SQL statement.
This bug also appears in 0.9.1. Now works fine with modified
mysql/mysqlconnection.py:
@@ -28,10 +28,6 @@
self.user = user
self.password = password
self.kw = {}
- if MySQLdb.version_info[:3] >= (1, 2, 1):
- self.need_unicode = True
- else:
- self.need_unicode = False
for key in ("unix_socket", "init_command",
"read_default_file", "read_default_group", "conv"):
if key in kw:
@@ -107,10 +103,6 @@
# done by calling ping(True) on the connection.
for count in range(3):
try:
- # For MySQLdb 1.2.1 and later, we go
- # encoding->unicode->charset (in the mysql db)
- if self.need_unicode and not isinstance(query, unicode):
- query = unicode(query, self.encoding)
return cursor.execute(query)
except MySQLdb.OperationalError, e:
if e.args[0] in (MySQLdb.constants.CR.SERVER_GONE_ERROR,
MySQLdb.constants.CR.SERVER_LOST):
and DB URI options: ?use_unicode=1&charset=utf8
It seems to me that the need_unicode stuff is somehow buggy and not
required, at least in my case.
----------------------------------------------------------------------
Comment By: Mirinde Fekus (junas)
Date: 2007-03-29 11:35
Message:
Logged In: YES
user_id=1304728
Originator: YES
SQLObject-0.8.1-py2.4
----------------------------------------------------------------------
Comment By: Oleg Broytmann (phd)
Date: 2007-03-28 23:27
Message:
Logged In: YES
user_id=4799
Originator: NO
What is the version of SQLObject?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=540672&aid=1690105&group_id=74338
|