From: Glenn M. <gle...@gm...> - 2008-01-07 17:56:08
|
Maybe I need to backup at bit. I am somewhat confused at this point. I need to insert a string which contains a non-ascii character into my database table, that character is Ch0xE9rie. E9 is the hex representation of the acute-e. Do I need unicode to do this, do I need to change the charset? What are my options? Thanks Glenn On Jan 7, 2008 12:45 PM, Oleg Broytmann <ph...@ph...> wrote: > On Mon, Jan 07, 2008 at 12:35:40PM -0500, Glenn MacGregor wrote: > > #!/usr/bin/python > > # -*- coding: utf-8 -*- > > > > import os, sys, glob MySQLdb > > from sqlobject import * > > > > sqlhub.processConnection = connectionForURI('mysql://test:test@localhost > > /test?charset=utf8&use_unicode=1 > > > > class Temp(SQLObject): > > class sqlmeta: > > table = "temp" > > fromDatabase = True > > > > def add(label): > > return Temp(label=label) > > > > add = staticmethod(add) > > > > > > a = 'Ch?rie' > > > > t = Temp.add(a) > > > > print 'Done' > > Declare the column as non-unicode: > > class Temp(SQLObject): > class sqlmeta: > table = "temp" > fromDatabase = True > > label = StringCol() > > > Or stop using unicode at all: > > sqlhub.processConnection = connectionForURI('mysql://test:test@localhost > /test') > > Oleg. > -- > Oleg Broytmann http://phd.pp.ru/ ph...@ph... > Programmers don't die, they just GOSUB without RETURN. > |