Changing Django Database Database from MySql to PostgreSQL

I am using Django 1.2 and 1.3 and MySql servers.

As soon as you get an error when migrating my MySql database using south:

! Error found during real run of migration! Aborting. ! Since you have a database that does not support running ! schema-altering statements in transactions, we have had ! to leave it in an interim state between migrations. ... ! The South developers regret this has happened, and would ! like to gently persuade you to consider a slightly ! easier-to-deal-with DBMS 

I was wondering if porting my databases from MySql to PostgreSQL could prevent this error. Secondly, will the transition from MySql to PostgreSQL be more active if you do not make dumpdata based on mysql, change the settings to point to PostgreSQL and loaddata on the new backend?

I saw this stack question, but it says its database is too large. I do not think it will be with my databases. I do not have any custom SQL commands in my Django projects.

+4
source share
1 answer

I'm tired of seeing this error using the South and yes, switching to PostgreSQL has expelled it!

The mysql2postgres application written in Ruby, suggested in the comments above, does not work for me (it will start, display some data on the screen, but not copy any data lines, for me). I do not know why. But with joy there rewrites Python, which worked flawlessly (for me, after all):
http://pypi.python.org/pypi/py-mysql2pgsql

The only thing I found is:

Initially, I thought it would be safer to set up tables in PostgreSQL db via syncdb, and then only transfer data. I tried this, but the tables are wrapped alphabetically, and this violates the foreign key restrictions for some tables (rows refer to rows in tables that have not yet been imported).

Then I tried structure + data transfer. This migrated fine, but I ran into some problems in Django, especially with the admin site. It appears that the migration script has created some table restrictions from what Django would have.

I solved this by hacking a mysql2pgsql script to respect the table order specified in the yml config only_tables , and then only migrate with + synchronization. With trial and error, I shuffled the ordering of the tables for my migration until all of them were successfully imported.

UPDATE:
My hack request described above was accepted, so you can do it now from the main version:
https://github.com/philipsoutham/py-mysql2pgsql

+5
source

Source: https://habr.com/ru/post/1384686/


All Articles