Difference between revisions of "Search an SQL database using sqlite3"
Jump to navigation
Jump to search
m (Simon moved page Search an SQL databaste using sqlite3 to Search an SQL database using sqlite3 without leaving a redirect) |
|||
Line 1: | Line 1: | ||
https://www.sqlite.org/index.html | |||
<code>sqlite</code> implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine to query <code>.sql</code> files. | |||
== Getting started == | |||
To use sqlite, you must have a valid metadata file with a <code>.db</code> file extension, and an installed version of SQL. This tutorial assumes knowledge of the command line. | |||
To start the sql engine, type: | |||
<syntaxhighlight lang="bash"> | |||
sqlite3 | |||
</syntaxhighlight> | |||
The prompt will change, showing that the sqlite engine has been initialised. To open a metadata file, type: | |||
<syntaxhighlight lang="sqlite"> | |||
.open filename.db | |||
</syntaxhighlight> | |||
You can then display tables with: | |||
<syntaxhighlight lang="sqlite"> | |||
.tables | |||
</syntaxhighlight> | |||
Based on what is returned, you can then query the content of each table with commands such as: | |||
<syntaxhighlight lang="sqlite"> | |||
SELECT * FROM users | |||
</syntaxhighlight> | |||
You may want to have a more human-readable view of the data that is printed in the terminal, by organising the headings and columns: | |||
<syntaxhighlight lang="sqlite" line> | |||
.headers ON | |||
.mode columns | |||
</syntaxhighlight> | |||
[[Category:Cookbook]] | [[Category:Cookbook]] | ||
[[Category:Sqlite]] | [[Category:Sqlite]] |
Revision as of 16:21, 14 November 2021
https://www.sqlite.org/index.html
sqlite
implements a small, fast, self-contained, high-reliability, full-featured, SQL database engine to query .sql
files.
Getting started
To use sqlite, you must have a valid metadata file with a .db
file extension, and an installed version of SQL. This tutorial assumes knowledge of the command line.
To start the sql engine, type:
sqlite3
The prompt will change, showing that the sqlite engine has been initialised. To open a metadata file, type:
.open filename.db
You can then display tables with:
.tables
Based on what is returned, you can then query the content of each table with commands such as:
SELECT * FROM users
You may want to have a more human-readable view of the data that is printed in the terminal, by organising the headings and columns:
.headers ON
.mode columns