Importing a SQLite3 dump back into the database Importing a SQLite3 dump back into the database sqlite sqlite

Importing a SQLite3 dump back into the database


You didn't specify your operating system and while

sqlite3 my_database.sqlite < export.sqlite3.sql

will work for the unix flavors, it will not work for windows.

The inverse of the .dump command is the .read command. The syntax would be

sqlite3> .read export.sqlite3.sql


This should also work:

echo '.read export.sqlite3.sql' | sqlite3 my_database.sqlite3

One possible advantage over "sqlite3 my_database.sqlite3 < export.sqlite3.sql" is that SQLite's .read command might (now or in the future) be more advanced than just "read in all the text and execute it." It might do batching, which would reduce memory usage for large dumps. I admit, though, that this is a pretty obscure and unlikely advantage. In all likelihood, .read simply reads each line from the input and executes it, just like the redirection and pipe operators.