How to export SQLite3 database to *.sql file

Here’s a quick way to export SQLite3 database to *.sql text file.

sqlite3 this.db .dump > this-db.sql

The command is useful for exporting SQLite database to standard ANSI .sql which can be imported into other database management system such as Oracle, MariaDB/MySQL, etc

How to convert between sqlite2 and sqlite3 database

Here’s a short guide on how to convert between sqlite2 to sqlite3 database file:

sqlite2 /path/to/mysqlite2.db .dump > backupfile
sqlite3 /path/to/mynewsqlite3.db < backupfile

Using the same method, you can convert sqlite3 db to sqlite2 db too!

p/s: Why you need to convert? because embedded device (read: iPhone and Android) only supports sqlite3 database, while PHP 5 by default supports sqlite2 database.

Thus, this method provide a convenient way to convert between the two different version of sqlite db format.

Recommended Reading