A Unicode curiosity: Thanks to UnicodeCol, you can store Unicode
values with SQLObject. You can even use Unicode strings as column/
attribute labels, more or less. But if you attempt to store a unicode
value into a column labeled with a Unicode string, you raise a
UnicodeDecodeError. (Now that I've figured this out, I'll go back to
make sure that I don't use Unicode strings as column labels, of course.)
This file, so_eg_unicode.py, dies on the last line.
cat so_eg_unicode.py
from sqlobject import *
sqlhub.processConnection = connectionForURI('sqlite:/:memory:')
class SCol(SQLObject):
pass
SCol.sqlmeta.addColumn(UnicodeCol('Col1'))
SCol.createTable()
class UCol(SQLObject):
pass
UCol.sqlmeta.addColumn(UnicodeCol(u'Col1'))
UCol.createTable()
sval="Chris"
uval=u'Pe\xf1a'
SCol(Col1=sval)
SCol(Col1=uval)
UCol(Col1=sval)
UCol(Col1=uval)
File "so_eg_unicode.py", line 19, in ?
UCol(Col1=uval)
File "/Library/Python/2.3/site-packages/SQLObject-0.9dev_r2175-
py2.3.egg/sqlobject/declarative.py", line 94, in _wrapper
return fn(self, *args, **kwargs)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/SQLObject-0.9dev_r2175-py2.3.egg/sqlobject/
main.py", line 1234, in __init__
self._create(id, **kw)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/SQLObject-0.9dev_r2175-py2.3.egg/sqlobject/
main.py", line 1264, in _create
self._SO_finishCreate(id)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/SQLObject-0.9dev_r2175-py2.3.egg/sqlobject/
main.py", line 1288, in _SO_finishCreate
id, names, values)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/SQLObject-0.9dev_r2175-py2.3.egg/sqlobject/
dbconnection.py", line 370, in queryInsertID
return self._runWithConnection(self._queryInsertID, soInstance,
id, names, values)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/SQLObject-0.9dev_r2175-py2.3.egg/sqlobject/
dbconnection.py", line 230, in _runWithConnection
val = meth(conn, *args)
File "/Library/Python/2.3/site-packages/SQLObject-0.9dev_r2175-
py2.3.egg/sqlobject/sqlite/sqliteconnection.py", line 214, in
_queryInsertID
q = self._insertSQL(table, names, values)
File "/Library/Python/2.3/site-packages/SQLObject-0.9dev_r2175-
py2.3.egg/sqlobject/sqlite/sqliteconnection.py", line 232, in _insertSQL
return DBAPI._insertSQL(self, table, names, values)
File "/System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/SQLObject-0.9dev_r2175-py2.3.egg/sqlobject/
dbconnection.py", line 362, in _insertSQL
return ("INSERT INTO %s (%s) VALUES (%s)" %
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position
3: ordinal not in range(128)
-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
sqlobject-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/sqlobject-discuss