Forums

Dumpdata and Loaddata

Hey PA, I'm trying to dumpdata from localhost and loaddata on PA, but when I try to loaddata I just get a Killed message.

I'm dumping the data locally like:

python manage.py dumpdata --natural-foreign --natural-primary -e contenttypes -e auth.Permission --indent 2 > dump2.json

And loading on PA like:

python manage.py loaddata dump2.json

Not sure what I'm doing wrong.

It could be due to memory crossing 3 GB limit on PythonAnywhere. The right way to do it is to use ssh tunnel and run loaddata locally. What database do you use?

My SQL file is 2.5gb and I tried this using SSH and it still gave me the killed message.

The size of the database file does not translate directly into the size it takes when loaded into memory. Use the JSONL serialisation format, so the file can be streamed without having to load the whole thing into memory: https://docs.djangoproject.com/en/4.1/topics/serialization/#serialization-formats

So that helped and now I don't see killed but I have an issue loading the data:

django.db.utils.IntegrityError: Problem installing fixture '/home/varand/fanclan/dump2.jsonl': Could not load api.RelatedTag(pk=006033b7-9838-44f0-8159-3b07ac55d3da): duplicate key value violates unique constraint "watson_searchentry_pkey" DETAIL:  Key (id)=(10) already exists.

and every time I run the loaddata the Key (id)=(10) already exists. increases by one.

You already have an entry in your database with that key, so you cannot add another entry from your dumped data into your database.