Frage

I want to connect to my MySQL database and insert some UTF8 strings. But when I do the insert query, some text like سسسسسسسسسسسسسسسس is inserted into my table.

This is my code:

s = QtCore.QString("insert into test4 values(''  , ' شسشس')");
self.onlineQuery.exec_(s);

What's wrong with my query?

Edit:

I solved the problem with this code:

QtCore.QTextCodec.setCodecForCStrings(QtCore.QTextCodec.codecForName("UTF-8"))
QtCore.QTextCodec.setCodecForLocale ( QtCore.QTextCodec.codecForName("UTF-8"))
War es hilfreich?

Lösung

Make sure the connection charset is set to UTF-8. This is not always the default.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top