4

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)?

2 Answers 2

11

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

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

Comments

10

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.

2 Comments

The "IntegrityError: columns app_label, model are not unique" error would show up when dumping all django's models and trying to load it. You can use "python manage.py dumpdata auth.User myapp1 myapp2" instead (only dump the User model from django).
Excellent tip, xhh. Wish I had seen this sooner.

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.