1
0
Fork 0
mirror of https://github.com/tldr-pages/tldr.git synced 2025-04-22 00:42:08 +02:00
tldr/pages/common/sqlite-utils.md
Vitor Henrique 61405c6e0e
pages*: fix small typos (#11850)
* pages*: fix small typos

* pages/*: make help and version commands consistent

* pages/*: follow "path/to/file" pattern

* nop: generic display help wording
2023-12-27 12:11:30 +05:30

1,001 B

sqlite-utils

Command-line tool used to manipulate SQLite databases in a number of different ways. More information: https://sqlite-utils.datasette.io/en/stable/cli.html.

  • Create a database:

sqlite-utils create-database {{path/to/database.db}}

  • Create a table:

sqlite-utils create-table {{path/to/database.db}} {{table_name}} {{id integer name text height float photo blob --pk id}}

  • List tables:

sqlite-utils tables {{path/to/database.db}}

  • Upsert a record:

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

  • Select records:

sqlite-utils rows {{path/to/database.db}} {{table_name}}

  • Delete a record:

sqlite-utils query {{path/to/database.db}} "{{delete from table_name where name = 'Tony Hoare'}}"

  • Drop a table:

sqlite-utils drop-table {{path/to/database.db}} {{table_name}}

  • Display help:

sqlite-utils -h