Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Transferring data between sqlite databases

Tags:

linux

sqlite

I am developing an application in Django using sqlite on windows.Will this db work on a linux machine? If not, how do i replicate the data on the new db on linux (creating scripts is one way)?

like image 437
kost Avatar asked Jun 02 '09 05:06

kost


2 Answers

SQLite is compatible with both Windows and Linux platforms.

The database file format is cross-platform - you can freely copy a database between 32-bit and 64-bit systems or between big-endian and little-endian architectures. These features make SQLite a popular choice as an Application File Format.

Source: http://sqlite.org/about.html

like image 122
Robert Harvey Avatar answered Sep 26 '22 13:09

Robert Harvey


As Robert writes, SQLite files should work on any platform. If you decide to switch to MySQL or PostgreSql you can run the following (standard) command to save your database on the Windows machine:

manage.py dumpdata <app1> <app1> > mydbdump.json

and then configure the settings.py on the Linux machine for the MySQL or PostgreSql database and run:

manage.py syncdb
manage.py loaddata ./mydbdump.json

I have successfuly done this on several occasions to switch from MySQL to SQLite it worked fine.

Just for reference, you can omit the listing in the dumpdata command to dump data for all installed apps but it will not be possible to load it back in. The all-inclusive dump will contain some internal Django records such as default content types and user authentication which are also created by the syncdb command. So you get errors like

IntegrityError: columns app_label, model are not unique

List the specific apps that you want to dump and load and it will work.

like image 25
Tomas Andrle Avatar answered Sep 26 '22 13:09

Tomas Andrle