By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,626 Members | 1,146 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,626 IT Pros & Developers. It's quick & easy.

inserting unicode strings in jython

P: 2
Hi - with the Jython site being down, info here on the following has been difficult to come by!

I'm trying to insert a unicode string into the following table:
CREATE TABLE `p1` (
`id` int(11) NOT NULL auto_increment,
`description` text,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8

I'm using jython's zxJDBC classes
from com.ziclix.python.sql import zxJDBC

I'm trying to insert u'Al\u221A\xA9ab' into the databse using:
str = u'Al\u221A\xA9mm' # Alémm
c = db.cursor()
c.execute("insert into p1 (description) values( '" + str + "')")
db.commit()

However, when I fetch the result, it is:
'Al?\xAC\xA9mm'

I've read several articles on unicode, but don't know if the zxjdbc driver is converting the string or if I need to set some properties.

Any help or insight will be much, much appreciated!

Thanks!
Oct 14 '06 #1
Share this Question
Share on Google+
2 Replies


bartonc
Expert 5K+
P: 6,596
AFAIK, there are two versions of (MySQL? I'm guessing from innodb). One has unicode support, the other dosn't. Have you tried posting to the MySQL forum?
Oct 14 '06 #2

P: 2
Thanks - I will follow up on it. Yes, you can have multiple db types in mysql (innodb and myisam). The reason I think this is a driver issue, possibly, or a config setting I am missing, is that I can go to the sql client and insert the string, and it gets stored as unicode (i'm guessing w/ utf-8 encoding).

When I insert the string using the client, and retrieve it using python, it shows up as a unicode string (in my previous post). However, when I try and re-insert that string, it goes in jacked up.

So, I'm guessing the issue is with Python (well, Jython) driver, or with some setting I am not using correctly.

Thanks.
Oct 14 '06 #3

Post your reply

Sign in to post your reply or Sign up for a free account.