473,324 Members | 2,214 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,324 software developers and data experts.

inserting unicode strings in jython

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
2 2746
bartonc
6,596 Expert 4TB
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
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

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

Similar topics

5
by: Jan Gregor | last post by:
Hello I found that price of += operator on string is too high in jython. For example 5000 such operations took 90 seconds (i generated html copy of table with 1000 rows and 5 columns)....
4
by: webdev | last post by:
lo all, some of the questions i'll ask below have most certainly been discussed already, i just hope someone's kind enough to answer them again to help me out.. so i started a python 2.3...
2
by: Neil Schemenauer | last post by:
python-dev@python.org.] The PEP has been rewritten based on a suggestion by Guido to change str() rather than adding a new built-in function. Based on my testing, I believe the idea is...
5
by: Jamie | last post by:
I have a file that was written using Java and the file has unicode strings. What is the best way to deal with these in C? The file definition reads: Data Field Description CHAR File...
1
by: shorti | last post by:
Hello, I am running DB2 UDB 8.2 on AIX 5.3. I am running some tests on converting several tables on an existing database to Unicode. The database will not be converted to unicode...just this...
2
by: Thomas Guettler | last post by:
Hi, is it possible to force all non ascii strings to be unicode strings somehow? Sometimes I forget that I need to write u'...' if the string contains an umlaut. I get an exception in django...
24
by: Donn Ingle | last post by:
Hello, I hope someone can illuminate this situation for me. Here's the nutshell: 1. On start I call locale.setlocale(locale.LC_ALL,''), the getlocale. 2. If this returns "C" or anything...
13
by: George Sakkis | last post by:
It seems xml.etree.cElementTree.iterparse() is not unicode aware: .... print elem.text .... Traceback (most recent call last): File "<stdin>", line 1, in <module> File "<string>", line 64,...
6
by: gita ziabari | last post by:
Hello All, The following code does not work for unicode characters: keyword = dict() kw = 'ÇÅÎÓËÉÈ' keyword.setdefault(key, ).append (kw) It works fine for inserting ASCII character. Any...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.