How do I use sqlite-utils? It’s time to learn how to manage an SQLite database.

I wrote up a tldr PR for sqlite-utils command, and here’s the usage with a person.db.

sqlite-utils

A command-line tool used to manage SQLite databases.

More information: https://sqlite-utils.datasette.io/en/stable/cli.html.

Create a database

sqlite-utils create-database person.db

Create a table

sqlite-utils create-table person.db people id integer name text height float photo blob --pk id

Upsert a record

echo '[ {"id": 1, "name": "Linus Torvalds"}, {"id": 2, "name": "Steve Wozniak"}, {"id": 3, "name": "Tony Hoare"} ]' | sqlite-utils upsert person.db people - --pk id

Select records

sqlite-utils rows person.db people

Delete a record

sqlite-utils query person.db "delete from people where name = 'Tony Hoare'"

Drop a table

sqlite-utils drop-table person.db people

Show help information:

sqlite-utils -h