Open a SQLite database in the terminal
March 27, 2021 ‐ 2 min read
SQLite databases are quite convenient in web development, when prototyping a simple website for example. It comes as the default database for a couple big web frameworks like Ruby on Rails and Django. Mind that none of them also encourage you to use SQLite in production.
There are graphical database browsers available for SQLite, but you can open a SQLite database in the terminal as well. To open a SQLite database in shell mode you enter the
sqlite3 command followed by the path to your database file.
$ sqlite3 db.sqlite3 SQLite version 3.31.1 2020-01-27 19:55:54 Enter ".help" for usage hints. sqlite>
You can now run SQL queries from the SQLite shell. Besides that there are many commands available, all starting with a period(
.). One of those commands is actually mentioned when you open the shell:
.help. When you run this
.help command you will see a list of available commands in the SQLite shell.
A couple useful SQLite shell commands are:
|List names and files of attached databases|
|Dump the database in a SQL text format|
|Display the output of next command in spreadsheet|
|Exit this program|
|Show a list of available commands|
|Write in-memory database into FILE|
|Show the CREATE statements|
|List names of tables|