Warning: Can't synchronize with repository "(default)" (Unsupported version control system "svn": No module named svn). Look in the Trac log for more information.

Ticket #1337 (closed defect: fixed)

Opened 12 years ago

Last modified 12 years ago

SQLObject and international characters

Reported by: mettwoch Owned by: anonymous
Priority: normal Milestone: 1.0.2
Component: SQLObject Version: 1.0.1
Severity: normal Keywords:


Problem inserting special non-ASCII chars with SQLObject

Default codepage in use is CP850:

import sys print sys.stdout.encoding


But here something goes wrong:

name = rs.Fields("MarqueLib?").Value name


c = Category(name=name, description=None, parent=None)

Traceback (most recent call last):

File "<console>", line 1, in ? File "c:\python24\lib\site-packages\SQLObject-0.7.3-py2.4.egg\sqlobject\declar

ative.py", line 93, in _wrapper

return fn(self, *args, kwargs)

File "c:\python24\lib\site-packages\SQLObject-0.7.3-py2.4.egg\sqlobject\main.p

y", line 1205, in init

self._create(id, kw)

File "c:\python24\lib\site-packages\SQLObject-0.7.3-py2.4.egg\sqlobject\main.p

y", line 1229, in _create


File "c:\python24\lib\site-packages\SQLObject-0.7.3-py2.4.egg\sqlobject\main.p

y", line 1088, in set

kw[name] = dbValue = from_python(value, self._SO_validatorState)

File "c:\python24\lib\site-packages\SQLObject-0.7.3-py2.4.egg\sqlobject\col.py

", line 525, in from_python

return value.encode("ascii")

UnicodeEncodeError?: 'ascii' codec can't encode character u'\xe9' in position 6: ordinal not in range(128)

Using MySQL with utf8

Model definition for "Category"

class Category(SQLObject):

name = UnicodeCol?(length=120, varchar=True) description = UnicodeCol?() products = RelatedJoin?("Product") parent = ForeignKey?("Category") childs = MultipleJoin?("Category", joinColumn="parent_id")

This drives me crazy. I just want to get rid of a legacy M$-Access app and now I can't figure out what I'm doing wrong here. I need to store strings in a variety of languages and I really don't know if I'm facing a bug in SQLObject or if I'm doing something wrong.


Change History

comment:1 Changed 12 years ago by mettwoch

Forgot to mention that all this happens in the "tg-admin shell". The legacy db import beeing a one-shot action the "shell" is just fine, but I should check how it behaves in a quick and dirty tg controller...

comment:2 Changed 12 years ago by mettwoch

I tried in a controller and the same happens ...

I've written a small sandbox app (1 table and 1 form) and when i fill in a foreign character in the field of the form I get the same encoding error. What is funny is that the form displays the value correctly (the value was filled in with MySQL QueryBrowser?).

Please help ... I become really frustrated

comment:3 Changed 12 years ago by mettwoch

  • Status changed from new to closed
  • Resolution set to fixed

I've found the missing information myself. Simply put this in the connection URI:


Thx anyway

Note: See TracTickets for help on using tickets.