Reputation: 1
I created my database with MySql and set collation as utf8_unicode_ci. And I query data in python program as this code
db = MySQLdb.connect(host="localhost",user="root",passwd="password",db="database",charset="utf8",use_unicode=True)
cur = db.cursor()
cur.execute("select `name` from car_park where p_id=1" )
rows=cur.fetchall()
print(rows)
But the out put is u'\u0e40\u0e14\u0e2d\u0e30\u0e21\u0e2d\u0e25\u0e4c'. Actually the data source in database is Thai language. Anyone else have been query data from database in Thai language or another UTF-8 by python please help. Thanks.
Upvotes: 0
Views: 166
Reputation: 401
rows
seems to be a list and you should iterate over it.
for row in rows:
print row
Printing a unicode object shouldn't make mistakes.
Upvotes: 1