This commit is contained in:
Simon Willison 2025-12-16 21:56:17 -08:00
commit 8d185d4c9f

View file

@ -131,7 +131,7 @@ See :ref:`cli_query`.
-r, --raw Raw output, first column of first row -r, --raw Raw output, first column of first row
--raw-lines Raw output, first column of each row --raw-lines Raw output, first column of each row
-p, --param <TEXT TEXT>... Named :parameters for SQL query -p, --param <TEXT TEXT>... Named :parameters for SQL query
--functions TEXT Python code defining one or more custom SQL --functions TEXT Python code or file path defining custom SQL
functions functions
--load-extension TEXT Path to SQLite extension, with optional --load-extension TEXT Path to SQLite extension, with optional
:entrypoint :entrypoint
@ -174,7 +174,7 @@ See :ref:`cli_memory`.
sqlite-utils memory animals.csv --schema sqlite-utils memory animals.csv --schema
Options: Options:
--functions TEXT Python code defining one or more custom SQL --functions TEXT Python code or file path defining custom SQL
functions functions
--attach <TEXT FILE>... Additional databases to attach - specify alias and --attach <TEXT FILE>... Additional databases to attach - specify alias and
filepath filepath
@ -270,6 +270,7 @@ See :ref:`cli_inserting_data`, :ref:`cli_insert_csv_tsv`, :ref:`cli_insert_unstr
--nl Expect newline-delimited JSON --nl Expect newline-delimited JSON
-c, --csv Expect CSV input -c, --csv Expect CSV input
--tsv Expect TSV input --tsv Expect TSV input
--empty-null Treat empty strings as NULL
--lines Treat each line as a single value called 'line' --lines Treat each line as a single value called 'line'
--text Treat input as a single value called 'text' --text Treat input as a single value called 'text'
--convert TEXT Python code to convert each item --convert TEXT Python code to convert each item
@ -280,13 +281,16 @@ See :ref:`cli_inserting_data`, :ref:`cli_insert_csv_tsv`, :ref:`cli_insert_unstr
--no-headers CSV file has no header row --no-headers CSV file has no header row
--encoding TEXT Character encoding for input, defaults to utf-8 --encoding TEXT Character encoding for input, defaults to utf-8
--batch-size INTEGER Commit every X records --batch-size INTEGER Commit every X records
--stop-after INTEGER Stop after X records
--alter Alter existing table to add any missing columns --alter Alter existing table to add any missing columns
--not-null TEXT Columns that should be created as NOT NULL --not-null TEXT Columns that should be created as NOT NULL
--default <TEXT TEXT>... Default value that should be set for a column --default <TEXT TEXT>... Default value that should be set for a column
-d, --detect-types Detect types for columns in CSV/TSV data -d, --detect-types Detect types for columns in CSV/TSV data (default)
--no-detect-types Treat all CSV/TSV columns as TEXT
--analyze Run ANALYZE at the end of this operation --analyze Run ANALYZE at the end of this operation
--load-extension TEXT Path to SQLite extension, with optional :entrypoint --load-extension TEXT Path to SQLite extension, with optional :entrypoint
--silent Do not show progress bar --silent Do not show progress bar
--strict Apply STRICT mode to created table
--ignore Ignore records if pk already exists --ignore Ignore records if pk already exists
--replace Replace records if pk already exists --replace Replace records if pk already exists
--truncate Truncate table before inserting records, if table --truncate Truncate table before inserting records, if table
@ -324,6 +328,7 @@ See :ref:`cli_upsert`.
--nl Expect newline-delimited JSON --nl Expect newline-delimited JSON
-c, --csv Expect CSV input -c, --csv Expect CSV input
--tsv Expect TSV input --tsv Expect TSV input
--empty-null Treat empty strings as NULL
--lines Treat each line as a single value called 'line' --lines Treat each line as a single value called 'line'
--text Treat input as a single value called 'text' --text Treat input as a single value called 'text'
--convert TEXT Python code to convert each item --convert TEXT Python code to convert each item
@ -334,13 +339,16 @@ See :ref:`cli_upsert`.
--no-headers CSV file has no header row --no-headers CSV file has no header row
--encoding TEXT Character encoding for input, defaults to utf-8 --encoding TEXT Character encoding for input, defaults to utf-8
--batch-size INTEGER Commit every X records --batch-size INTEGER Commit every X records
--stop-after INTEGER Stop after X records
--alter Alter existing table to add any missing columns --alter Alter existing table to add any missing columns
--not-null TEXT Columns that should be created as NOT NULL --not-null TEXT Columns that should be created as NOT NULL
--default <TEXT TEXT>... Default value that should be set for a column --default <TEXT TEXT>... Default value that should be set for a column
-d, --detect-types Detect types for columns in CSV/TSV data -d, --detect-types Detect types for columns in CSV/TSV data (default)
--no-detect-types Treat all CSV/TSV columns as TEXT
--analyze Run ANALYZE at the end of this operation --analyze Run ANALYZE at the end of this operation
--load-extension TEXT Path to SQLite extension, with optional :entrypoint --load-extension TEXT Path to SQLite extension, with optional :entrypoint
--silent Do not show progress bar --silent Do not show progress bar
--strict Apply STRICT mode to created table
-h, --help Show this message and exit. -h, --help Show this message and exit.
@ -368,12 +376,13 @@ See :ref:`cli_bulk`.
Options: Options:
--batch-size INTEGER Commit every X records --batch-size INTEGER Commit every X records
--functions TEXT Python code defining one or more custom SQL functions --functions TEXT Python code or file path defining custom SQL functions
--flatten Flatten nested JSON objects, so {"a": {"b": 1}} becomes --flatten Flatten nested JSON objects, so {"a": {"b": 1}} becomes
{"a_b": 1} {"a_b": 1}
--nl Expect newline-delimited JSON --nl Expect newline-delimited JSON
-c, --csv Expect CSV input -c, --csv Expect CSV input
--tsv Expect TSV input --tsv Expect TSV input
--empty-null Treat empty strings as NULL
--lines Treat each line as a single value called 'line' --lines Treat each line as a single value called 'line'
--text Treat input as a single value called 'text' --text Treat input as a single value called 'text'
--convert TEXT Python code to convert each item --convert TEXT Python code to convert each item
@ -450,20 +459,25 @@ See :ref:`cli_transform_table`.
--rename column2 column_renamed --rename column2 column_renamed
Options: Options:
--type <TEXT CHOICE>... Change column type to INTEGER, TEXT, FLOAT or BLOB --type <TEXT CHOICE>... Change column type to INTEGER, TEXT, FLOAT,
--drop TEXT Drop this column REAL or BLOB
--rename <TEXT TEXT>... Rename this column to X --drop TEXT Drop this column
-o, --column-order TEXT Reorder columns --rename <TEXT TEXT>... Rename this column to X
--not-null TEXT Set this column to NOT NULL -o, --column-order TEXT Reorder columns
--not-null-false TEXT Remove NOT NULL from this column --not-null TEXT Set this column to NOT NULL
--pk TEXT Make this column the primary key --not-null-false TEXT Remove NOT NULL from this column
--pk-none Remove primary key (convert to rowid table) --pk TEXT Make this column the primary key
--default <TEXT TEXT>... Set default value for this column --pk-none Remove primary key (convert to rowid table)
--default-none TEXT Remove default from this column --default <TEXT TEXT>... Set default value for this column
--drop-foreign-key TEXT Drop foreign key constraint for this column --default-none TEXT Remove default from this column
--sql Output SQL without executing it --add-foreign-key <TEXT TEXT TEXT>...
--load-extension TEXT Path to SQLite extension, with optional :entrypoint Add a foreign key constraint from a column to
-h, --help Show this message and exit. another table with another column
--drop-foreign-key TEXT Drop foreign key constraint for this column
--sql Output SQL without executing it
--load-extension TEXT Path to SQLite extension, with optional
:entrypoint
-h, --help Show this message and exit.
.. _cli_ref_extract: .. _cli_ref_extract:
@ -591,9 +605,9 @@ See :ref:`cli_convert`.
Convert columns using Python code you supply. For example: Convert columns using Python code you supply. For example:
sqlite-utils convert my.db mytable mycolumn \ sqlite-utils convert my.db mytable mycolumn \
'"\n".join(textwrap.wrap(value, 10))' \ '"\n".join(textwrap.wrap(value, 10))' \
--import=textwrap --import=textwrap
"value" is a variable with the column value to be converted. "value" is a variable with the column value to be converted.
@ -601,32 +615,35 @@ See :ref:`cli_convert`.
The following common operations are available as recipe functions: The following common operations are available as recipe functions:
r.jsonsplit(value, delimiter=',', type=<class 'str'>) r.jsonsplit(value: 'str', delimiter: 'str' = ',', type: 'Callable[[str],
object]' = <class 'str'>) -> 'str'
Convert a string like a,b,c into a JSON array ["a", "b", "c"] Convert a string like a,b,c into a JSON array ["a", "b", "c"]
r.parsedate(value, dayfirst=False, yearfirst=False, errors=None) r.parsedate(value: 'str', dayfirst: 'bool' = False, yearfirst: 'bool' = False,
errors: 'Optional[object]' = None) -> 'Optional[str]'
Parse a date and convert it to ISO date format: yyyy-mm-dd Parse a date and convert it to ISO date format: yyyy-mm-dd
- dayfirst=True: treat xx as the day in xx/yy/zz - dayfirst=True: treat xx as the day in xx/yy/zz
- yearfirst=True: treat xx as the year in xx/yy/zz - yearfirst=True: treat xx as the year in xx/yy/zz
- errors=r.IGNORE to ignore values that cannot be parsed - errors=r.IGNORE to ignore values that cannot be parsed
- errors=r.SET_NULL to set values that cannot be parsed to null - errors=r.SET_NULL to set values that cannot be parsed to null
r.parsedatetime(value, dayfirst=False, yearfirst=False, errors=None) r.parsedatetime(value: 'str', dayfirst: 'bool' = False, yearfirst: 'bool' =
False, errors: 'Optional[object]' = None) -> 'Optional[str]'
Parse a datetime and convert it to ISO datetime format: yyyy-mm-ddTHH:MM:SS Parse a datetime and convert it to ISO datetime format: yyyy-mm-ddTHH:MM:SS
- dayfirst=True: treat xx as the day in xx/yy/zz - dayfirst=True: treat xx as the day in xx/yy/zz
- yearfirst=True: treat xx as the year in xx/yy/zz - yearfirst=True: treat xx as the year in xx/yy/zz
- errors=r.IGNORE to ignore values that cannot be parsed - errors=r.IGNORE to ignore values that cannot be parsed
- errors=r.SET_NULL to set values that cannot be parsed to null - errors=r.SET_NULL to set values that cannot be parsed to null
You can use these recipes like so: You can use these recipes like so:
sqlite-utils convert my.db mytable mycolumn \ sqlite-utils convert my.db mytable mycolumn \
'r.jsonsplit(value, delimiter=":")' 'r.jsonsplit(value, delimiter=":")'
Options: Options:
--import TEXT Python modules to import --import TEXT Python modules to import
@ -641,8 +658,8 @@ See :ref:`cli_convert`.
--output-type [integer|float|blob|text] --output-type [integer|float|blob|text]
Column type to use for the output column Column type to use for the output column
--drop Drop original column afterwards --drop Drop original column afterwards
--no-skip-false Don't skip falsey values
-s, --silent Don't show a progress bar -s, --silent Don't show a progress bar
--pdb Open pdb debugger on first error
-h, --help Show this message and exit. -h, --help Show this message and exit.
@ -909,6 +926,7 @@ See :ref:`cli_create_table`.
--replace If table already exists, replace it --replace If table already exists, replace it
--transform If table already exists, try to transform the schema --transform If table already exists, try to transform the schema
--load-extension TEXT Path to SQLite extension, with optional :entrypoint --load-extension TEXT Path to SQLite extension, with optional :entrypoint
--strict Apply STRICT mode to created table
-h, --help Show this message and exit. -h, --help Show this message and exit.
@ -1030,21 +1048,6 @@ disable-fts
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_tui:
tui
===
::
Usage: sqlite-utils tui [OPTIONS]
Open Textual TUI.
Options:
-h, --help Show this message and exit.
.. _cli_ref_optimize: .. _cli_ref_optimize:
optimize optimize
@ -1144,7 +1147,7 @@ See :ref:`cli_add_column`.
:: ::
Usage: sqlite-utils add-column [OPTIONS] PATH TABLE COL_NAME Usage: sqlite-utils add-column [OPTIONS] PATH TABLE COL_NAME
[[integer|float|blob|text|INTEGER|FLOAT|BLOB|TEXT]] [[integer|int|float|real|text|str|blob|bytes]]
Add a column to the specified table Add a column to the specified table
@ -1180,8 +1183,6 @@ See :ref:`cli_add_foreign_key`.
sqlite-utils add-foreign-key my.db books author_id authors id sqlite-utils add-foreign-key my.db books author_id authors id
WARNING: Could corrupt your database! Back up your database file first.
Options: Options:
--ignore If foreign key already exists, do nothing --ignore If foreign key already exists, do nothing
--load-extension TEXT Path to SQLite extension, with optional :entrypoint --load-extension TEXT Path to SQLite extension, with optional :entrypoint
@ -1337,6 +1338,25 @@ See :ref:`cli_duplicate_table`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_rename_table:
rename-table
============
See :ref:`cli_renaming_tables`.
::
Usage: sqlite-utils rename-table [OPTIONS] PATH TABLE NEW_NAME
Rename this table.
Options:
--ignore If table does not exist, do nothing
--load-extension TEXT Path to SQLite extension, with optional :entrypoint
-h, --help Show this message and exit.
.. _cli_ref_drop_table: .. _cli_ref_drop_table:
drop-table drop-table
@ -1417,13 +1437,14 @@ See :ref:`cli_install`.
:: ::
Usage: sqlite-utils install [OPTIONS] PACKAGES... Usage: sqlite-utils install [OPTIONS] [PACKAGES]...
Install packages from PyPI into the same environment as sqlite-utils Install packages from PyPI into the same environment as sqlite-utils
Options: Options:
-U, --upgrade Upgrade packages to latest version -U, --upgrade Upgrade packages to latest version
-h, --help Show this message and exit. -e, --editable TEXT Install a project in editable mode from this path
-h, --help Show this message and exit.
.. _cli_ref_uninstall: .. _cli_ref_uninstall:
@ -1498,4 +1519,19 @@ See :ref:`cli_spatialite_indexes`.
-h, --help Show this message and exit. -h, --help Show this message and exit.
.. _cli_ref_plugins:
plugins
=======
::
Usage: sqlite-utils plugins [OPTIONS]
List installed plugins
Options:
-h, --help Show this message and exit.
.. [[[end]]] .. [[[end]]]