Skip to content

SQLite Commands and Tips

Christopher Hopkins edited this page Jan 13, 2014 · 5 revisions

SQLite is a lightweight, portable database which can be very useful in development environments. Here are some tips on some common commands.

Open/Create a Database

$ sqlite3 database_file.db

If the file does not exist, then sqlite will create it, otherwise, it will open it.

Execute a query against a database

$ sqlite3 database_file.db "select * from table"

If you want to make the response easier to read then, add the '-csv' '-header' options. For example:

$ sqlite3 -csv -header database_file.db "select * from table"

To create a csv file, use the above example and redirect the output to a file.

Clone this wiki locally