MySQL Forums
Forum List  »  Connector/Python

Re: Cannot display MySQL latin2_croation_ci characters in Python script
Posted by: Geert Vanderkelen
Date: April 24, 2013 05:33AM

Hi Paul,

Just to confirm, you are using 'latin2' or ISO 8859-2 character encoding. The collation is not really important here.

You did not say where you are displaying your data, but I'm guessing you are using some shell, using Gnome Terminal or Apple's? If you are using a console/terminal, make sure it is using 'latin2' encoding.

The bellow script shows how to do it. Make sure to save it as latin2. If you execute it, it should print correctly. Note how the table is created. And, again, make sure that the terminal where you print the data is using latin2 (ISO 8859-2).


#!/usr/bin/env python
# -*- coding: latin2 -*-

import mysql.connector

'user': 'root',
'database': 'test',
'use_unicode': False,
'charset': 'latin2',

cnx = mysql.connector.connect(**DBCONFIG)

cur = cnx.cursor()
cur.execute("DROP TABLE IF EXISTS croatian")
"CREATE TABLE croatian (c1 VARCHAR(100)) "
"CHARACTER SET 'latin2' COLLATE 'latin2_croatian_ci'")

data = [
("Stanišić & Simatović",),
("Boškoski & Tarčulovski",),
("Ražnatović, Željko",),

cur.executemany("INSERT INTO croatian (c1) VALUES (%s)", data)

cur.execute("SELECT c1 FROM croatian")
for row in cur:


Geert Vanderkelen
Software Developer at Oracle

Options: ReplyQuote

Written By
Re: Cannot display MySQL latin2_croation_ci characters in Python script
April 24, 2013 05:33AM

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.