Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

sqlite

Trying to convert an SqlCe database to SQLite, I export it to a .sql file. Now how would I use sqlite.exe to create a database from this .sql file?

Where to put the sql3.exe file?
What command syntax to use, in cmd prompt or in the sqlite.exe shell?

like image 649
bretddog Avatar asked Feb 09 '13 15:02

bretddog


1 Answers

Use following command line:

sqlite3 -init dump.sql newsqlite.db ""

It will create new SQLite database file newsqlite.db by executing statements from dump.sql. Empty string "" is needed for sqlite3 to quit automatically.

If newsqlite.db file already existed with some data, import may fail unless you use IF NOT EXISTS for all table and index creation statements.

like image 94
mvp Avatar answered Jan 03 '23 10:01

mvp