[Django] #35819: sqlite3.ProgrammingError while python manage.py dumpdata > dump.json

9 views
Skip to first unread message

Django

unread,
Oct 7, 2024, 10:15:22 AM10/7/24
to django-...@googlegroups.com
#35819: sqlite3.ProgrammingError while python manage.py dumpdata > dump.json
-------------------------------------+-------------------------------------
Reporter: DragonwolfAside | Type: Bug
Status: new | Component: Core
| (Management commands)
Version: 5.1 | Severity: Normal
Keywords: dumpdata | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Python 3.12.4 Django 5.1.1

Having difficulty dumping sql with pipe
{{{
C:\Users\Admin\Desktop\Projects\django-project>python manage.py dumpdata >
dump.json
CommandError: Unable to serialize database: 'gbk' codec can't encode
character '\xa0' in position 70: illegal multibyte sequence
Exception ignored in: <generator object cursor_iter at 0x000001FA8E382020>
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-
packages\django\db\models\sql\compiler.py", line 2115, in cursor_iter
cursor.close()
sqlite3.ProgrammingError: Cannot operate on a closed database.
}}}

but following command runs well

{{{
C:\Users\Admin\Desktop\Projects\django-project>python manage.py dumpdata

[{"model": "admin.logentry", "pk": 1, "fields": {"action_time":
"2024-10-06T20:31:44.362", "user": 1, "content_type": 6, "object_id": "1",
...
}}}

chcp 65001 also didn't work, perhaps Chinese language system make the
default encoding to gbk, leading to a serialize error, then the cursor
closes.
--
Ticket URL: <https://code.djangoproject.com/ticket/35819>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Oct 7, 2024, 10:17:41 AM10/7/24
to django-...@googlegroups.com
#35819: sqlite3.ProgrammingError while python manage.py dumpdata > dump.json
-------------------------------------+-------------------------------------
Reporter: DragonwolfAside | Owner: (none)
Type: Bug | Status: new
Component: Core (Management | Version: 5.1
commands) |
Severity: Normal | Resolution:
Keywords: dumpdata | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Description changed by DragonwolfAside:

Old description:

> Python 3.12.4 Django 5.1.1
>
> Having difficulty dumping sql with pipe
> {{{
> C:\Users\Admin\Desktop\Projects\django-project>python manage.py dumpdata
> > dump.json
> CommandError: Unable to serialize database: 'gbk' codec can't encode
> character '\xa0' in position 70: illegal multibyte sequence
> Exception ignored in: <generator object cursor_iter at
> 0x000001FA8E382020>
> Traceback (most recent call last):
> File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-
> packages\django\db\models\sql\compiler.py", line 2115, in cursor_iter
> cursor.close()
> sqlite3.ProgrammingError: Cannot operate on a closed database.
> }}}
>
> but following command runs well
>
> {{{
> C:\Users\Admin\Desktop\Projects\django-project>python manage.py dumpdata
>
> [{"model": "admin.logentry", "pk": 1, "fields": {"action_time":
> "2024-10-06T20:31:44.362", "user": 1, "content_type": 6, "object_id":
> "1", ...
> }}}
>
> chcp 65001 also didn't work, perhaps Chinese language system make the
> default encoding to gbk, leading to a serialize error, then the cursor
> closes.

New description:

Python 3.12.4 Django 5.1.1

Having difficulty while dumping sql data with pipes
{{{
C:\Users\Admin\Desktop\Projects\django-project>python manage.py dumpdata >
dump.json
CommandError: Unable to serialize database: 'gbk' codec can't encode
character '\xa0' in position 70: illegal multibyte sequence
Exception ignored in: <generator object cursor_iter at 0x000001FA8E382020>
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python312\Lib\site-
packages\django\db\models\sql\compiler.py", line 2115, in cursor_iter
cursor.close()
sqlite3.ProgrammingError: Cannot operate on a closed database.
}}}

but following command runs well

{{{
C:\Users\Admin\Desktop\Projects\django-project>python manage.py dumpdata

[{"model": "admin.logentry", "pk": 1, "fields": {"action_time":
"2024-10-06T20:31:44.362", "user": 1, "content_type": 6, "object_id": "1",
...
}}}

chcp 65001 also didn't work, perhaps Chinese language system make the
default encoding to gbk, leading to a serialize error, then the cursor
closes.

--
--
Ticket URL: <https://code.djangoproject.com/ticket/35819#comment:1>

Django

unread,
Oct 7, 2024, 10:48:08 AM10/7/24
to django-...@googlegroups.com
#35819: sqlite3.ProgrammingError while python manage.py dumpdata > dump.json
-------------------------------------+-------------------------------------
Reporter: DragonwolfAside | Owner: (none)
Type: Bug | Status: closed
Component: Core (Management | Version: 5.1
commands) |
Severity: Normal | Resolution: invalid
Keywords: dumpdata | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Simon Charette):

* resolution: => invalid
* status: new => closed

Comment:

It appears has more to with your shell environment than Django itself; you
most likely have an improper locale defined.

In doubt use utf-8 but how this can be accomplished should be discussed
here as this ticket tracker is meant to track issues with Django itself.

TicketClosingReasons/UseSupportChannels
--
Ticket URL: <https://code.djangoproject.com/ticket/35819#comment:2>
Reply all
Reply to author
Forward
0 new messages