Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8254041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T01:04:35+00:00 2026-06-08T01:04:35+00:00

I’ve run into an issue trying to set up automatic backups on my site.

  • 0

I’ve run into an issue trying to set up automatic backups on my site. The problem boils down to the following.

I open the Python shell and I call the dumpdata command twice. It works for the first time and it returns empty list the second time. After that all further dumpdata calls return empty list:

>>> python manage.py shell
>>> from django.core.management import call_command
>>> call_command("dumpdata")
[{"pk": 1, (...) // lots of data //
>>> call_command("dumpdata")
>>> []

To make it work again I need to restart the python shell.

Edit: I use Django 1.4 and Python 2.6

Edit2: My current hypothesis is that the problem is related to this issue: https://code.djangoproject.com/ticket/5423 – 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?

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?

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: https://code.djangoproject.com/ticket/10813 . Why the DB error during the first dumpdata wasn’t explicitely reported remains a mystery to me.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T01:04:36+00:00Added an answer on June 8, 2026 at 1:04 am

    I see that django is messing something with transactions.

    I executed a simple example under the debugger:

    # test.py
    from django.core.management import call_command
    call_command("dumpdata")
    print "\n---"
    call_command("dumpdata")
    print
    

    And called it like:

    DJANGO_SETTINGS_MODULE=settings python test.py > log.txt
    

    My log.txt ended with “—\n[]\n”

    After running it in the debugger i found, deep down in
    django.core.management.commands.dumpdata.handle()
    that model.objects.all() keeps returning [].

    I called model.objects.iterator(), and got the exception:

    (Pdb) list(model.objects.iterator())
    *** Error in argument: '(model.objects.iterator())'
    (Pdb) p list(model.objects.iterator())
    *** DatabaseError: DatabaseError('current transaction is aborted, commands ignored    until end of transaction block\n',)
    (Pdb) 
    

    So, I hacked together code, which plays with the transaction itself:

    # test.py version 2.0!
    
    #!/usr/bin/env python
    # from django.core.management import call_command
    import django.core.management as mgmt
    from django.db import transaction
    
    ''' 
    try:
        import settings # Assumed to be in the same directory.
    except ImportError:
        import sys
        sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
        sys.exit(1)
    '''
    
    @transaction.commit_manually
    def main():
        # mgmt.call_command('dumpdata', use_base_manager=True)
        mgmt.call_command('dumpdata')
        transaction.rollback()
        print
        print '---'
        print
        """ 
        mgmt._commands = None
        import sys
        reload(sys.modules['django.core.management.commands.dumpdata'])
        """
        mgmt.call_command('dumpdata')
        transaction.rollback()
        print
    
    if __name__ == "__main__":
        main()
    

    This spits out the whole database – every time!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a French site that I want to parse, but am running into
I am currently running into a problem where an element is coming back from
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I would like to run a str_replace or preg_replace which looks for certain words
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.