MySQL Forums
Forum List  »  Connector/Python

Re: arabic text insertion problem
Posted by: Geert Vanderkelen
Date: February 24, 2010 04:44AM

First fixing your Python code: you should do it this way (category and name can be input from some website):

db = my.connect(user='root',db='test',charset='utf8')
cur = db.cursor()
name = 'a'
category = '\xd8\xb6'
s = "INSERT INTO animal (name, category) VALUES (%s,%s)"
cur.execute(s, (name,category))


Next, '\xd8\xb6' is not 'latin1', it's also not part of the Arabic character encoding ISO-8859-6 (please correct me if I'm wrong).
If you set the the charset to utf8 as shown above, it should work.
You got to make sure your input is UTF8, and I think it is, at least '\xd8\xb6' is.

Geert Vanderkelen
Software Developer at Oracle

Options: ReplyQuote


Subject
Written By
Posted
February 21, 2010 03:28AM
Re: arabic text insertion problem
February 24, 2010 04:44AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.