4

I would like to convert my Django project's database from MySQL to PostgreSQL. Unfortunately, I can't just use Django's "dumpdata" and "loaddata" management commands because my database tables are too big. I already read the article http://www.ofbrooklyn.com/2010/07/18/migrating-django-mysql-postgresql-easy-way/, but it seems that to use this method in practice I'll still need to turn it into something like a management command that iterates over available models when it copies model instances and when resets sequences. Besides, it doesn't seem very fast either because it issues save() on each model instance.

Is there a better way to migrate? Actually, I would prefer to do "mysqldump", convert the dump from MySQL to PostgreSQL format somehow and then load it to PostgreSQL. What piece of software would you recommend that could perform such dump conversion and correctly convert from MySQL data types to PostgreSQL ones, for example tinyint(1) to boolean?

Edit Thanks everyone for your help. I successfully migrated my database using https://github.com/maxlapshin/mysql2postgres utility. However, I still had to reset sequences in the resulting PostgreSQL database myself after importing the dump.

1
  • I have deleted my answer. Next time I will read for twice the question. Good luck with your migration! Commented Dec 5, 2011 at 12:33

2 Answers 2

3

There are several converters for it, for example this one in Ruby: https://github.com/maxlapshin/mysql2postgres

Sign up to request clarification or add additional context in comments.

2 Comments

Thank you, got to try this one. I already heard about it but I didn't know that it can also generate db dumps.
I found the python rewrite of that Ruby script worked better for me: stackoverflow.com/questions/8895374/…
0

If your dataset is large and you need to do any transformation you can use open source solutions like talend studio and the kettle project from pentaho to create a map and it will take care of the rest; but this might be overkill unless you want to do any transformation as well (or your data set is really, really big).

EnterpriseDB (the company behind postgresql) provide a data migration studio product that does this along with a guide if you want to do it yourself.

The py-mysql2pgsql python package is another option.

1 Comment

I had some experience with Talend Studio and Pentaho and I would NEVER suggest to use them for this purposes. KIS - use small, simple, yet efficient tool for specific operation. Using a hammer to nail an hear-ring isn't good idea...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.