1

here in this table https://www.db-fiddle.com/f/mU8RhMyiNb6RBjdaYZztci/0

i try to insert two names girisken, girişken and for mysql this is a duplicate and the second one can not be insert because the first exists and i am fine

but in python when i do

a = 'girisken'
b = 'girişken'
print(a == b)

it gives me false and that makes problems trying to insert it to mysql

how to solve this problem?

my collation is utf8mb4_unicode_520_ci in mysql

Sammitch
  • 30,782
  • 7
  • 50
  • 77
yvgwxgtyowvaiqndwo
  • 367
  • 1
  • 2
  • 10
  • This might be helpful : https://stackoverflow.com/questions/14173421/use-string-translate-in-python-to-transliterate-cyrillic – Marshall C Jun 17 '22 at 19:10

1 Answers1

1

Character equivalence is based on the collation.

In MySQL's default collation utf8mb4_0900_ai_ci, 's' is equal to 'ş':

mysql> select 'girisken' = 'girişken' as same;
+------+
| same |
+------+
|    1 |
+------+

I infer that this word is from the Türkçe language (I assume since the country now wants to be known as Türkiye, their language maybe should be known as Türkçe?).

So the proper collation should be chosen for that language:

mysql> select 'girisken' = 'girişken' collate utf8mb4_turkish_ci as same;
+------+
| same |
+------+
|    0 |
+------+

Or in MySQL 8.0, an updated collation is available:

mysql> select 'girisken' = 'girişken' collate utf8mb4_tr_0900_ai_ci as same;
+------+
| same |
+------+
|    0 |
+------+
Bill Karwin
  • 538,548
  • 86
  • 673
  • 828
  • if i wanna keep the collation as it is. can i make the data i get from mysql be encoded in a way where my programming language can recognise? – yvgwxgtyowvaiqndwo Jun 17 '22 at 19:20
  • You would have to change the characters in the words you store to some character that is not equal to `'s'` in the default collation. IMO, I would change the collation at least on your `name` column. You don't have to change the default collation for the whole server or even the whole table. You can change a collation of a single column. – Bill Karwin Jun 17 '22 at 19:27