Note that there are some explanatory texts on larger screens.

plurals
  1. PODjango - consecutive dumpdata calls fail, even though work correctly when run separately
    primarykey
    data
    text
    <p>I've run into an issue trying to set up automatic backups on my site. The problem boils down to the following.</p> <p>I open the Python shell and I call the dumpdata command twice. It <strong>works</strong> for the first time and it returns <strong>empty list</strong> the second time. After that all further dumpdata calls return empty list:</p> <pre><code>&gt;&gt;&gt; python manage.py shell &gt;&gt;&gt; from django.core.management import call_command &gt;&gt;&gt; call_command("dumpdata") [{"pk": 1, (...) // lots of data // &gt;&gt;&gt; call_command("dumpdata") &gt;&gt;&gt; [] </code></pre> <p>To make it work again I need to restart the python shell.</p> <p>Edit: I use Django 1.4 and Python 2.6</p> <p>Edit2: My current hypothesis is that the problem is related to this issue: <a href="https://code.djangoproject.com/ticket/5423" rel="nofollow">https://code.djangoproject.com/ticket/5423</a> - identified 5 years ago and according to Django 1.5 release notes, to-be resolved in the next release. Does anybody have an idea how to workaround this issue without altering the 1.4 framework code being run on the machine?</p> <p>Edit3: However sql dump of the whole database is only 0.5 MB, which makes it rather unprobable that the serialization is running out of memory. And anyway, wouldn't I get an explicit error in such case?</p> <p>Edit4: Mystery solved. As Tomasz Gandor correctly determined, the problem was that shell executes the commands in one transaction, and after one of the commands causes DBError, further DB calls are ignored, as described here: <a href="https://code.djangoproject.com/ticket/10813" rel="nofollow">https://code.djangoproject.com/ticket/10813</a> . Why the DB error during the first dumpdata wasn't explicitely reported remains a mystery to me.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload