-1

For my website in Python, before changing my database from SQLite to MySQL I saved it as a JSON file :

python manage.py dumpdata > datadump.json

Then I changed my settings.py to the MySQL database to migrate it:

python manage.py loaddata datadump.json

But it causes this error:

  File "C:\Users\M.Hawa\Desktop\My_Django_Stuff\firstproject\deneme\lib\site-packages\django\core\serializers\json.py", line 67, in Deserializer
    stream_or_string = stream_or_string.decode()
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x99 in position 5289: invalid start byte

I tried to change :

stream_or_string = stream_or_string.decode()

To:

stream_or_string = stream_or_string.decode("UTF-16")

But it did not work.

user4157124
  • 2,809
  • 13
  • 27
  • 42

1 Answers1

0

In these character sets: armscii8, dec8, greek, hebrew, hp8, latin2, latin5, latin7, tis620, 0x99 represents ; is that what you expected?

Is the code in Python? Is it a literal in the code? If so, have you stated that Python is using utf8? (Apparently not.) Or did the value come from somewhere else? Where?

See "best practice" in Trouble with UTF-8 characters; what I see is not what I stored

I thought JSON only allowed utf8; check the usage of it for that dump.

Rick James
  • 135,179
  • 13
  • 127
  • 222