Ivan
Ivan

Reputation: 64207

How to execute an sql script file against an SQLite 3 database file?

What is an SQLite 3 (3.7.11) analogue of MySQL's

mysql -p -u username database_name < file.sql

to execute all the queries in a given SQL script file against a specified database?

Upvotes: 35

Views: 38393

Answers (2)

Jacek Siciarek
Jacek Siciarek

Reputation: 92

The following should work as well:

 echo "SELECT id, username, email FROM fos_user_user;" | sqlite3 app/data.db3

Upvotes: 6

user610650
user610650

Reputation:

This should work:

[someone@somewhere ~]$ echo "select * from sometable;" > file.sql
[someone@somewhere ~]$ sqlite3 file.db < file.sql 
10/02/2012
11/01/2012
09/03/2012

Upvotes: 66

Related Questions