Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
runs-on: ${{ matrix.os }}
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
python-version: ["3.10", "3.11", "3.12", "3.13", "3.14", "3.15-dev"]
numpy: [0, 1]
os: [ubuntu-latest, macos-latest, windows-latest, macos-14]
steps:
Expand Down Expand Up @@ -46,7 +46,7 @@ jobs:
- name: run flake8
run: flake8
- name: run ty
if: matrix.os != 'windows-latest'
if: matrix.os != 'windows-latest' && matrix.python-version == '3.14'
run: |
pip install uv
uv run ty check sqlite_utils
Expand Down
139 changes: 72 additions & 67 deletions docs/cli-reference.rst
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,15 @@ See :ref:`cli_query`.
--tsv Output TSV
--no-headers Omit CSV headers
-t, --table Output as a formatted table
--fmt TEXT Table format - one of asciidoc, double_grid,
double_outline, fancy_grid, fancy_outline, github,
grid, heavy_grid, heavy_outline, html, jira,
latex, latex_booktabs, latex_longtable, latex_raw,
mediawiki, mixed_grid, mixed_outline, moinmoin,
orgtbl, outline, pipe, plain, presto, pretty,
psql, rounded_grid, rounded_outline, rst, simple,
simple_grid, simple_outline, textile, tsv,
unsafehtml, youtrack
--fmt TEXT Table format - one of asciidoc, colon_grid,
double_grid, double_outline, fancy_grid,
fancy_outline, github, grid, heavy_grid,
heavy_outline, html, jira, latex, latex_booktabs,
latex_longtable, latex_raw, mediawiki, mixed_grid,
mixed_outline, moinmoin, orgtbl, outline, pipe,
plain, presto, pretty, psql, rounded_grid,
rounded_outline, rst, simple, simple_grid,
simple_outline, textile, tsv, unsafehtml, youtrack
--json-cols Detect JSON cols and output them as JSON, not
escaped strings
-r, --raw Raw output, first column of first row
Expand Down Expand Up @@ -186,15 +186,15 @@ See :ref:`cli_memory`.
--tsv Output TSV
--no-headers Omit CSV headers
-t, --table Output as a formatted table
--fmt TEXT Table format - one of asciidoc, double_grid,
double_outline, fancy_grid, fancy_outline, github,
grid, heavy_grid, heavy_outline, html, jira,
latex, latex_booktabs, latex_longtable, latex_raw,
mediawiki, mixed_grid, mixed_outline, moinmoin,
orgtbl, outline, pipe, plain, presto, pretty,
psql, rounded_grid, rounded_outline, rst, simple,
simple_grid, simple_outline, textile, tsv,
unsafehtml, youtrack
--fmt TEXT Table format - one of asciidoc, colon_grid,
double_grid, double_outline, fancy_grid,
fancy_outline, github, grid, heavy_grid,
heavy_outline, html, jira, latex, latex_booktabs,
latex_longtable, latex_raw, mediawiki, mixed_grid,
mixed_outline, moinmoin, orgtbl, outline, pipe,
plain, presto, pretty, psql, rounded_grid,
rounded_outline, rst, simple, simple_grid,
simple_outline, textile, tsv, unsafehtml, youtrack
--json-cols Detect JSON cols and output them as JSON, not
escaped strings
-r, --raw Raw output, first column of first row
Expand Down Expand Up @@ -425,14 +425,15 @@ See :ref:`cli_search`.
--tsv Output TSV
--no-headers Omit CSV headers
-t, --table Output as a formatted table
--fmt TEXT Table format - one of asciidoc, double_grid,
double_outline, fancy_grid, fancy_outline, github,
grid, heavy_grid, heavy_outline, html, jira, latex,
latex_booktabs, latex_longtable, latex_raw, mediawiki,
mixed_grid, mixed_outline, moinmoin, orgtbl, outline,
pipe, plain, presto, pretty, psql, rounded_grid,
rounded_outline, rst, simple, simple_grid,
simple_outline, textile, tsv, unsafehtml, youtrack
--fmt TEXT Table format - one of asciidoc, colon_grid,
double_grid, double_outline, fancy_grid, fancy_outline,
github, grid, heavy_grid, heavy_outline, html, jira,
latex, latex_booktabs, latex_longtable, latex_raw,
mediawiki, mixed_grid, mixed_outline, moinmoin, orgtbl,
outline, pipe, plain, presto, pretty, psql,
rounded_grid, rounded_outline, rst, simple,
simple_grid, simple_outline, textile, tsv, unsafehtml,
youtrack
--json-cols Detect JSON cols and output them as JSON, not escaped
strings
--load-extension TEXT Path to SQLite extension, with optional :entrypoint
Expand Down Expand Up @@ -690,14 +691,15 @@ See :ref:`cli_tables`.
--tsv Output TSV
--no-headers Omit CSV headers
-t, --table Output as a formatted table
--fmt TEXT Table format - one of asciidoc, double_grid,
double_outline, fancy_grid, fancy_outline, github,
grid, heavy_grid, heavy_outline, html, jira, latex,
latex_booktabs, latex_longtable, latex_raw, mediawiki,
mixed_grid, mixed_outline, moinmoin, orgtbl, outline,
pipe, plain, presto, pretty, psql, rounded_grid,
rounded_outline, rst, simple, simple_grid,
simple_outline, textile, tsv, unsafehtml, youtrack
--fmt TEXT Table format - one of asciidoc, colon_grid,
double_grid, double_outline, fancy_grid, fancy_outline,
github, grid, heavy_grid, heavy_outline, html, jira,
latex, latex_booktabs, latex_longtable, latex_raw,
mediawiki, mixed_grid, mixed_outline, moinmoin, orgtbl,
outline, pipe, plain, presto, pretty, psql,
rounded_grid, rounded_outline, rst, simple,
simple_grid, simple_outline, textile, tsv, unsafehtml,
youtrack
--json-cols Detect JSON cols and output them as JSON, not escaped
strings
--columns Include list of columns for each table
Expand Down Expand Up @@ -731,14 +733,15 @@ See :ref:`cli_views`.
--tsv Output TSV
--no-headers Omit CSV headers
-t, --table Output as a formatted table
--fmt TEXT Table format - one of asciidoc, double_grid,
double_outline, fancy_grid, fancy_outline, github,
grid, heavy_grid, heavy_outline, html, jira, latex,
latex_booktabs, latex_longtable, latex_raw, mediawiki,
mixed_grid, mixed_outline, moinmoin, orgtbl, outline,
pipe, plain, presto, pretty, psql, rounded_grid,
rounded_outline, rst, simple, simple_grid,
simple_outline, textile, tsv, unsafehtml, youtrack
--fmt TEXT Table format - one of asciidoc, colon_grid,
double_grid, double_outline, fancy_grid, fancy_outline,
github, grid, heavy_grid, heavy_outline, html, jira,
latex, latex_booktabs, latex_longtable, latex_raw,
mediawiki, mixed_grid, mixed_outline, moinmoin, orgtbl,
outline, pipe, plain, presto, pretty, psql,
rounded_grid, rounded_outline, rst, simple,
simple_grid, simple_outline, textile, tsv, unsafehtml,
youtrack
--json-cols Detect JSON cols and output them as JSON, not escaped
strings
--columns Include list of columns for each view
Expand Down Expand Up @@ -777,15 +780,15 @@ See :ref:`cli_rows`.
--tsv Output TSV
--no-headers Omit CSV headers
-t, --table Output as a formatted table
--fmt TEXT Table format - one of asciidoc, double_grid,
double_outline, fancy_grid, fancy_outline, github,
grid, heavy_grid, heavy_outline, html, jira,
latex, latex_booktabs, latex_longtable, latex_raw,
mediawiki, mixed_grid, mixed_outline, moinmoin,
orgtbl, outline, pipe, plain, presto, pretty,
psql, rounded_grid, rounded_outline, rst, simple,
simple_grid, simple_outline, textile, tsv,
unsafehtml, youtrack
--fmt TEXT Table format - one of asciidoc, colon_grid,
double_grid, double_outline, fancy_grid,
fancy_outline, github, grid, heavy_grid,
heavy_outline, html, jira, latex, latex_booktabs,
latex_longtable, latex_raw, mediawiki, mixed_grid,
mixed_outline, moinmoin, orgtbl, outline, pipe,
plain, presto, pretty, psql, rounded_grid,
rounded_outline, rst, simple, simple_grid,
simple_outline, textile, tsv, unsafehtml, youtrack
--json-cols Detect JSON cols and output them as JSON, not
escaped strings
--load-extension TEXT Path to SQLite extension, with optional
Expand Down Expand Up @@ -817,14 +820,15 @@ See :ref:`cli_triggers`.
--tsv Output TSV
--no-headers Omit CSV headers
-t, --table Output as a formatted table
--fmt TEXT Table format - one of asciidoc, double_grid,
double_outline, fancy_grid, fancy_outline, github,
grid, heavy_grid, heavy_outline, html, jira, latex,
latex_booktabs, latex_longtable, latex_raw, mediawiki,
mixed_grid, mixed_outline, moinmoin, orgtbl, outline,
pipe, plain, presto, pretty, psql, rounded_grid,
rounded_outline, rst, simple, simple_grid,
simple_outline, textile, tsv, unsafehtml, youtrack
--fmt TEXT Table format - one of asciidoc, colon_grid,
double_grid, double_outline, fancy_grid, fancy_outline,
github, grid, heavy_grid, heavy_outline, html, jira,
latex, latex_booktabs, latex_longtable, latex_raw,
mediawiki, mixed_grid, mixed_outline, moinmoin, orgtbl,
outline, pipe, plain, presto, pretty, psql,
rounded_grid, rounded_outline, rst, simple,
simple_grid, simple_outline, textile, tsv, unsafehtml,
youtrack
--json-cols Detect JSON cols and output them as JSON, not escaped
strings
--load-extension TEXT Path to SQLite extension, with optional :entrypoint
Expand Down Expand Up @@ -856,14 +860,15 @@ See :ref:`cli_indexes`.
--tsv Output TSV
--no-headers Omit CSV headers
-t, --table Output as a formatted table
--fmt TEXT Table format - one of asciidoc, double_grid,
double_outline, fancy_grid, fancy_outline, github,
grid, heavy_grid, heavy_outline, html, jira, latex,
latex_booktabs, latex_longtable, latex_raw, mediawiki,
mixed_grid, mixed_outline, moinmoin, orgtbl, outline,
pipe, plain, presto, pretty, psql, rounded_grid,
rounded_outline, rst, simple, simple_grid,
simple_outline, textile, tsv, unsafehtml, youtrack
--fmt TEXT Table format - one of asciidoc, colon_grid,
double_grid, double_outline, fancy_grid, fancy_outline,
github, grid, heavy_grid, heavy_outline, html, jira,
latex, latex_booktabs, latex_longtable, latex_raw,
mediawiki, mixed_grid, mixed_outline, moinmoin, orgtbl,
outline, pipe, plain, presto, pretty, psql,
rounded_grid, rounded_outline, rst, simple,
simple_grid, simple_outline, textile, tsv, unsafehtml,
youtrack
--json-cols Detect JSON cols and output them as JSON, not escaped
strings
--load-extension TEXT Path to SQLite extension, with optional :entrypoint
Expand Down
1 change: 1 addition & 0 deletions docs/cli.rst
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,7 @@ Available ``--fmt`` options are:
.. ]]]

- ``asciidoc``
- ``colon_grid``
- ``double_grid``
- ``double_outline``
- ``fancy_grid``
Expand Down
6 changes: 4 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ dependencies = [

[dependency-groups]
dev = [
"black>=24.1.1",
"black>=26.3.1",
"cogapp",
"hypothesis",
"pytest",
Expand All @@ -47,7 +47,9 @@ dev = [
# flake8
"flake8",
"flake8-pyproject",
"ty",
"ty>=0.0.37",
# For stable cog:
"tabulate>=0.10.0",
]
docs = [
"beanbag-docutils>=2.0",
Expand Down
26 changes: 10 additions & 16 deletions sqlite_utils/cli.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import base64
from typing import Any
import click
from click_default_group import DefaultGroup # type: ignore
from click_default_group import DefaultGroup
from datetime import datetime, timezone
import hashlib
import pathlib
Expand Down Expand Up @@ -42,7 +42,6 @@
TypeTracker,
)


CONTEXT_SETTINGS = dict(help_option_names=["-h", "--help"])


Expand Down Expand Up @@ -223,7 +222,7 @@ def _iter():
else:
items = db.table_names(fts4=fts4, fts5=fts5)
for name in items:
row = [name]
row: list[Any] = [name]
if counts:
row.append(method(name).count)
if columns:
Expand Down Expand Up @@ -2122,8 +2121,9 @@ def _execute_query(
cursor = [[cursor.rowcount]]
else:
headers = [c[0] for c in cursor.description]
cursor_or_rows: Any = cursor
if raw:
row = cursor.fetchone() # type: ignore[union-attr]
row = cursor_or_rows.fetchone()
data = row[0] if row else None
if isinstance(data, bytes):
sys.stdout.buffer.write(data)
Expand Down Expand Up @@ -2911,17 +2911,15 @@ def _analyze(db, tables, columns, save, common_limit=10, no_most=False, no_least
)
details = (
(
textwrap.dedent(
"""
textwrap.dedent("""
{table}.{column}: ({i}/{total})

Total rows: {total_rows}
Null rows: {num_null}
Blank rows: {num_blank}

Distinct values: {num_distinct}{most_common_rendered}{least_common_rendered}
"""
)
""")
.strip()
.format(
i=i + 1,
Expand Down Expand Up @@ -2968,8 +2966,7 @@ def uninstall(packages, yes):


def _generate_convert_help():
help = textwrap.dedent(
"""
help = textwrap.dedent("""
Convert columns using Python code you supply. For example:

\b
Expand All @@ -2982,8 +2979,7 @@ def _generate_convert_help():
Use "-" for CODE to read Python code from standard input.

The following common operations are available as recipe functions:
"""
).strip()
""").strip()
recipe_names = [
n
for n in dir(recipes)
Expand All @@ -2997,15 +2993,13 @@ def _generate_convert_help():
name, str(inspect.signature(fn)), textwrap.dedent(fn.__doc__.rstrip())
)
help += "\n\n"
help += textwrap.dedent(
"""
help += textwrap.dedent("""
You can use these recipes like so:

\b
sqlite-utils convert my.db mytable mycolumn \\
'r.jsonsplit(value, delimiter=":")'
"""
).strip()
""").strip()
return help


Expand Down
Loading
Loading