0

I want to use Cyrillic characters with my simple web app (flask with MySQL DB).

DB charset is set = cp1251 / collation = cp1251_general_ci Charset/collation is specified during application connection to DB as follows:

application.config['SQLALCHEMY_DATABASE_URI'] = f'mysql+mysqlconnector://{creds["user"]}:{creds["pass"]}@{creds["host"]}:{creds["port"]}/{creds["dbname"]}?**charset=cp1251&collation=cp1251_general_ci**'

p.s. It's a small flask web app (pet project). Btw before I used Postgres with no problems (no bothering about charsets/collation). But I had to migrate to MySQL as Postgres is expensive to host @ AWS RDS. So I migrated to MySQL @ some free hosting.

When entering Latin characters it works / when entering Cyrillic letters it stores "????"

Cannot understand what's causing the problem. Thanks for your help!

pjcunningham
  • 7,676
  • 1
  • 36
  • 49
  • 1
    Switch to [UTF-8 Everywhere](https://utf8everywhere.org/). Further reading at [UTF-8 all the way through](https://stackoverflow.com/questions/279170/). – JosefZ Jan 22 '23 at 14:58
  • Used utf8mb4. It helped finally. Thank you! – Volodymyr Mazur Jan 23 '23 at 21:51
  • More on Question marks in https://stackoverflow.com/questions/38363566/trouble-with-utf8-characters-what-i-see-is-not-what-i-stored – Rick James Jan 24 '23 at 02:14

0 Answers0