Use manage.py dumpdata, and loaddata?

1,110 views
Skip to first unread message

Dawei Shen

unread,
Nov 19, 2009, 9:07:32 AM11/19/09
to django...@googlegroups.com
Hi, all,

I have been developing a website, where I use the same postgresql
database server for both development and production. Now that I have
had many users and a significant amount of data, I am trying to use
sqlite3 engine when I do development locally instead of connecting to
the production server. In my settings.py, I have something that looks
like:

if ON_PRODUCTION_SERVER: DATABASE_ENGINE  = "postgresql_psycopg2" ...
else: DATABASE_ENGINE = "sqlite3" ...

My task right now is to dump data (I wish to dump all of them) from
the production server, and install them in the local sqlite database.
This is what I did:

python manage.py dumpdata > data.json

Then, I switched to sqlite3 database, and did

python manage.py syncdb
python manage.py loaddata data.json

However, I met the following errors:

Installing json fixture 'data' from absolute path.
Problem installing fixture 'data.json': Traceback (most recent call
last):
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/core/management/commands/loaddata.py",
line 153, in handle
   obj.save()
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/core/serializers/base.py", line 163, in
save
   models.Model.save_base(self.object, raw=True)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/base.py", line 474, in
save_base
   rows = manager.filter(pk=pk_val)._update(values)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/query.py", line 444, in
_update
   return query.execute_sql(None)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/sql/subqueries.py", line 120,
in execute_sql
   cursor = super(UpdateQuery, self).execute_sql(result_type)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/models/sql/query.py", line 2369, in
execute_sql
   cursor.execute(sql, params)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/backends/util.py", line 19, in
execute
   return self.cursor.execute(sql, params)
 File "/Users/sachi/Workspace/socialmobility/pinax/pinax-env/lib/
python2.6/site-packages/django/db/backends/sqlite3/base.py", line 193,
in execute
   return Database.Cursor.execute(self, query, params)
IntegrityError: columns app_label, model are not unique


Could anybody let me know why this error happened, and how I get
correctly dump/load data?

Thanks a lot!

Sachi

Russell Keith-Magee

unread,
Nov 19, 2009, 9:16:39 AM11/19/09
to django...@googlegroups.com
This sounds like you've hit ticket #7052. The ticket description in
Trac explains the problem, as well as some possible workarounds.

The good news is that there will hopefully be a solution for this in
v1.2. I've been working on it recently, and hope to be able to commit
soon.

Yours,
Russ Magee %-)
Reply all
Reply to author
Forward
0 new messages