Hi.
I know that utf-8 is a good choice, but i have old not mine project written in Perl and that stores data in MySQL in KOI8-R encoding. Python supports this encoding, MySQLdb - not :( How can i add KOI8-R encoding support?
Note: MySQL knows it as "koi8r", Python as "koi8-r" or "koi8_r". If I set charset='koi8-r' in database connection i get an error:
_mysql_exceptions.OperationalError: (2019, "Can't initialize character set koi8-r (path: /usr/share/mysql/charsets/)"). Yes, because only koi8r.xml file there and mysql knows koi8r encoding.
If I set charset='koi8r' as mysql knows in database connection i get:
File "mdbtest.py", line 10, in <module>
cur.execute("SELECT fio FROM user WHERE id = %s", (36500,))
File "/home/foger/Dev/Python/lib/python3.6/site-packages/MySQLdb/cursors.py", line 243, in execute
query = query.encode(db.encoding, 'surrogateescape')
LookupError: unknown encoding: koi8r
Hi. I know that utf-8 is a good choice, but i have old not mine project written in Perl and that stores data in MySQL in KOI8-R encoding. Python supports this encoding, MySQLdb - not :( How can i add KOI8-R encoding support?
Note: MySQL knows it as "koi8r", Python as "koi8-r" or "koi8_r". If I set charset='koi8-r' in database connection i get an error:
_mysql_exceptions.OperationalError: (2019, "Can't initialize character set koi8-r (path: /usr/share/mysql/charsets/)")
. Yes, because only koi8r.xml file there and mysql knows koi8r encoding.If I set charset='koi8r' as mysql knows in database connection i get:
MySQL example:
Please help!