Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best way to migrate a Django DB from SQLite to MySQL?

I need to migrate my db from sqlite to mysql, and the various tools/scripts out there are too many for me to easily spot the safest and most elegant solution.

This seemed to me nice http://djangosnippets.org/snippets/14/ but appears to be 3 years since getting an update which is worrying..

Can you recommend a solution that is known to be reliable with Django 1.1.1 ?

like image 360
GJ. Avatar asked Jun 14 '10 04:06

GJ.


People also ask

How do I migrate from SQLite to MySQL?

The quickest and easiest way to convert SQLite to MySQL is by exporting an SQL Database to a Dump File, and then importing the SQLite Dump into MySQL Database. You can export an SQLite Database to Dump File using the . dump command.

Is SQLite good for Django?

SQLite is pretty fast. In some cases, literally orders of magnitude faster than, say, Postgres, which comes up as a go-to alternative among Djangonauts. As someone pointed out, it also supports lots of concurrency. It's a matter of whether your app falls under the 'some cases' or not.

Which DB works best with Django?

MySQL and PostgreSQL work best with Django.


1 Answers

Execute:

python manage.py dumpdata > datadump.json 

Next, change your settings.py to the mysql database.

Finally:

python manage.py loaddata datadump.json 
like image 162
Martin Eve Avatar answered Sep 26 '22 12:09

Martin Eve