我目前正在使用sqlite3作为我的一个Django项目的数据库.我想改变它以使用postgresql,我想保持所有数据完好无损.
我曾经./manage.py dumpdata > dump.json
创建过数据转储,并将我的设置更改为使用postgresql.首先尝试使用空数据库./manage.py loaddata dump.json
导致表中存在错误,因此我运行了./manage.py syncdb
,然后再次尝试.这导致了这个错误:
Problem installing fixture 'dump.json': Traceback (most recent call last):
File "/usr/lib/python2.6/site-packages/django/core/management/commands/loaddata.py", line 163, in handle
obj.save()
File "/usr/lib/python2.6/site-packages/django/core/serializers/base.py", line 163, in save
models.Model.save_base(self.object, raw=True)
File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 495, in save_base
rows = manager.filter(pk=pk_val)._update(values)
File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 448, in _update
return query.execute_sql(None)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/subqueries.py", line 124, in execute_sql
cursor = super(UpdateQuery, self).execute_sql(result_type)
File "/usr/lib/python2.6/site-packages/django/db/models/sql/query.py", line 2347, in execute_sql
cursor.execute(sql, params)
File "/usr/lib/python2.6/site-packages/django/db/backends/util.py", line 19, in execute
return …
Run Code Online (Sandbox Code Playgroud)