0

Hi I am dvelopping an application in python with sqlalchemy and mysql 5.1.58-1ubuntu1, I can get data from db without problem, except that I can not read not ascii characters like è, ò or the euro symbol, instead of the euro I get
\u20ac
this is how I create the engine for mysqlalchemy

dbfile="root:########@localhost/parafarmacie"
engine = create_engine("mysql+mysqldb://"+dbfile+"?charset=utf8&use_unicode=0")

all my columns that work with text are declared as Unicode, I googled for days but without any luck, someone could tell me where is my mistake? thanks in advance

asked Feb 28, 2012 at 10:56

1 Answer 1

2

When you get your unicode objects from the database, before you output them, you need to encode them:

my_unicode_object.encode("utf-8")

What you are seeing now is the raw repr of the unicode object which shows you the code point (since it hasn't been converted to bytes yet) :-)

answered Feb 28, 2012 at 11:00
Sign up to request clarification or add additional context in comments.

1 Comment

\u20ac is in fact the Unicode codepoint of the Euro symbol. Your database logic is apparently fine.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.