Re: Please help me with unicode problem

Daniel Dittmar <[email protected]>
Newsgroups gmane.comp.db.maxdb
Message-ID <[email protected]>
대wrote:
> I use python interface module, and I use that very well.
> But I have a problem when I excute insert command.
> There are some Korean in that query sentence.
> After I excuted that command, the characters was not shown normaly.
> I tried many times to find what's the problem.
> I concluded that the characters was converted to latin.
> It's like unicode(str,'latin-1').
> But I need unicode(str,'euc-kr').

There is no way to automatically use a different encoding when inserting
ordinary (= non unicode) Python strings into unicode columns.

You could wrap the insert statement:

class Encoder:
    def __init__ (self, prepared):
        self.prepared = prepared

    def execute (self, args):
        converted = []
        for value in args:
            if type (value) == type (''):
                value = unicode(str,'euc-kr')
            converted.append (value)
        self.prepared.execute (converted)

use as
prepared = Encoder (session.prepare ('...'))
prepared.execute ([...])

Daniel


-- 
MaxDB Discussion Mailing List
For list archives: http://lists.mysql.com/maxdb
To unsubscribe:    http://lists.mysql.com/[email protected]
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.