Switching Django project from sqlite3 backend to postgresql failes when loading datadump -


I'm currently using sqlite3 as DB for one of my Django projects I use it postgresql I want to change, and I would like to retain all the data.

I used the ./td.py dumpdata & gt; Dump.json to create a dump of data, and change my settings to use postgresql ./management.py loaddata.dump.json with an empty database Trying, as a result of errors due to current table errors, I ran the ./ manage.py syncdb , and then tried again. The result of this error occurs in:

  Problems installing stability "dump Jason ': Traceback (most recent call final): File "/usr/lib/python2.6/site-packages/django/core/management/commands/loaddata.py", line 163, obj.save () file In the handle, "/usr/lib/python2.6/site-packages/django/core/serializers/base.py", line 163, to save the models. Models save_base (self.object, raw = true) File " /usr/lib/python2.6/site-packages/django/db/models/base.py ", line 495, save_base rows = manager in .filter (pk = pk_val) ._update (values) file" / usr / Lib / python2.6 / site-packages / django / db / models / query.py ", line 448, _update return query.execute_sql (none) in the file" /usr/lib/python2.6/site-packages/django /db/models/sql/subqueries.py ", line 124, execute _sql cursor = super (update, manually) .execute_sql (result_type) file "/ usr /lib/python2.6/site-packages/django/db/models/sql/query.py", line 2347, execute_sql cursor. Execute (SQL, Parameter) file "/usr/lib/python2.6/site-computer / Django / db /backends/util.py", line 19, execute self-cache. Exclusive (SQL, Parameters) IntegrityAir: Duplicate key value violates unique restriction "django_content_type_app_label_key"  
  • Is not this the right way to transfer data from one database to another?
  • What should I do to safely switch the DB backend?
  • The problem is that you are getting twice the defined content type - once When you do syncdb , and once you are trying to import the data from the export as you have other things in your database that are dependent on the original content type definitions, keep them I will advise

    Therefore, after running syncdb , do manage .py dbshell and remove all new defined content types in your database for TRUNCATE django_content_type; then you should not get any kind of conflicts - on that part of the process, in any case.


Comments