python manage.py dumpdata Unable to serialize database
Question:
I am trying to run the command
python manage.py dumpdata > data.json
However, I receive such a traceback:
CommandError: Unable to serialize database: 'charmap' codec can't encode characters in position 1-4: character maps to <undefined>
Exception ignored in: <generator object cursor_iter at 0x0000020E11353820>
Traceback (most recent call last):
File "C:UsersIlliaDesktopMyDjangoStuffgreatkartvenvlibsite-packagesdjangodbmodelssqlcompiler.py", line 1625, in cursor_iter
cursor.close()
sqlite3.ProgrammingError: Cannot operate on a closed database.
How to solve this issue?
Answers:
Running set PYTHONIOENCODING=utf-8
before python manage.py dumpdata > data.json
has solved the issue.
I couldn’t get the soloution above to work, however i did get this to work;
https://pypi.org/project/django-dump-load-utf8/
I installed it and used its command for dumping data and it worked, hope this helps anybody else! I think my problem was that my database had Norwegian letters in it "ÆØÅ"
if this doesn’t work, and if you are windows, try
python -Xutf8 ./manage.py dumpdata > data.json
I am trying to run the command
python manage.py dumpdata > data.json
However, I receive such a traceback:
CommandError: Unable to serialize database: 'charmap' codec can't encode characters in position 1-4: character maps to <undefined>
Exception ignored in: <generator object cursor_iter at 0x0000020E11353820>
Traceback (most recent call last):
File "C:UsersIlliaDesktopMyDjangoStuffgreatkartvenvlibsite-packagesdjangodbmodelssqlcompiler.py", line 1625, in cursor_iter
cursor.close()
sqlite3.ProgrammingError: Cannot operate on a closed database.
How to solve this issue?
Running set PYTHONIOENCODING=utf-8
before python manage.py dumpdata > data.json
has solved the issue.
I couldn’t get the soloution above to work, however i did get this to work;
https://pypi.org/project/django-dump-load-utf8/
I installed it and used its command for dumping data and it worked, hope this helps anybody else! I think my problem was that my database had Norwegian letters in it "ÆØÅ"
if this doesn’t work, and if you are windows, try
python -Xutf8 ./manage.py dumpdata > data.json