microsoft/mssql-django

[QUESTION]I user mssql-django and how to support chinese?When inserting Chinese using SQL , it was found from the database that it was garbled。

HeroZ09 opened this issue · 2 comments

I user mssql-django and how to support chinese? When inserting Chinese using SQL , it was found from the database that it was garbled。

For example:
**test sql below:**
sql_str= "insert into CHECK_TEST (id,TITLE,AUTHOR) values (6,‘**测试哈哈哈哈哈**’,'hero花')"
cursor.execute(sql_str)
**result below:**
(Decimal('6'), '**???????**', 'hero?', None)

I use django mssql setting below:
DATABASES = {
"default": {
"ENGINE": "mssql",
"NAME": "TEST",
"USER": "TEST",
"PASSWORD": TEST,
"HOST": "TEST",
}
}

You will need to change your database's collation to one of the Chinese options.

This doc shows you how to change it: https://learn.microsoft.com/en-us/sql/relational-databases/collations/set-or-change-the-database-collation?view=sql-server-ver16

This gives more information on which collation to choose: https://learn.microsoft.com/en-us/sql/relational-databases/collations/collation-and-unicode-support?view=sql-server-ver16

You will need to change your database's collation to one of the Chinese options.

This doc shows you how to change it: https://learn.microsoft.com/en-us/sql/relational-databases/collations/set-or-change-the-database-collation?view=sql-server-ver16

This gives more information on which collation to choose: https://learn.microsoft.com/en-us/sql/relational-databases/collations/collation-and-unicode-support?view=sql-server-ver16

OK,I will have a try~ thanks for your support~