How to use sqlite3.exe to create database from exported .sql script

Trying to convert a SqlCe database to SQLite, I export it to a file .sql

. Now how to use sqlite.exe

to create a database from this file .sql

?

Where to place the file sql3.exe

?
What command syntax should I use in the cmd prompt or in the shell sqlite.exe

?

+3


source to share


2 answers


Use the following command line:

sqlite3 -init dump.sql newsqlite.db ""

      



It will create a new SQLite database file by newsqlite.db

following the instructions from dump.sql

. An empty string is ""

required for sqlite3 to close automatically.

If the file newsqlite.db

already exists with some data, the import may fail if you do not use IF NOT EXISTS

table and index creation for all statements.

+5


source


Place sqlite3.exe

where you want, as long as you remember that place, and you can start sqlite3

from there.

Applying a script to a database (possibly just created) on the command line:

sqlite3.exe my-new-db.somesuffix < myscript.sql

      



Executing script in an interactive session sqlite3

:

sqlite3.exe my-new-db.somesuffix
....
.read myscript.sql
....

      

Both options are valid and usable. (Note: if yours .sql

was built for a non-sqlite database, I would expect sqlite3

some changes to work in order to work . And things like stored procedures and UDFs would definitely be lost).

+3


source







All Articles