sqlite-utils 4.0a1__tar.gz → 4.0rc1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {sqlite_utils-4.0a1/sqlite_utils.egg-info → sqlite_utils-4.0rc1}/PKG-INFO +3 -24
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/docs/changelog.rst +27 -1
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/docs/cli-reference.rst +118 -71
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/docs/cli.rst +45 -1
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/docs/contributing.rst +17 -34
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/docs/index.rst +1 -0
- sqlite_utils-4.0rc1/docs/migrations.rst +171 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/docs/python-api.rst +51 -1
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/pyproject.toml +29 -27
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils/__init__.py +2 -1
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils/cli.py +316 -103
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils/db.py +315 -224
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils/hookspecs.py +5 -2
- sqlite_utils-4.0rc1/sqlite_utils/migrations.py +126 -0
- sqlite_utils-4.0rc1/sqlite_utils/plugins.py +35 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils/recipes.py +21 -5
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils/utils.py +165 -74
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1/sqlite_utils.egg-info}/PKG-INFO +3 -24
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils.egg-info/SOURCES.txt +5 -0
- sqlite_utils-4.0rc1/sqlite_utils.egg-info/requires.txt +7 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/conftest.py +24 -5
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_analyze_tables.py +3 -7
- sqlite_utils-4.0rc1/tests/test_atomic.py +174 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_cli.py +32 -16
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_cli_convert.py +52 -6
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_cli_insert.py +18 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_cli_memory.py +21 -2
- sqlite_utils-4.0rc1/tests/test_cli_migrate.py +303 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_create.py +0 -1
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_default_value.py +0 -1
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_docs.py +4 -4
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_duplicate.py +2 -4
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_extract.py +2 -7
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_fts.py +24 -1
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_gis.py +2 -2
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_introspect.py +13 -9
- sqlite_utils-4.0rc1/tests/test_migrations.py +110 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_plugins.py +34 -1
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_recreate.py +5 -2
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_register_function.py +37 -30
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_rows_from_file.py +1 -1
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_tracer.py +3 -4
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_transform.py +2 -4
- sqlite_utils-4.0a1/sqlite_utils/plugins.py +0 -26
- sqlite_utils-4.0a1/sqlite_utils.egg-info/requires.txt +0 -32
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/LICENSE +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/MANIFEST.in +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/README.md +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/docs/installation.rst +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/docs/plugins.rst +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/docs/reference.rst +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/setup.cfg +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils/__main__.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils/py.typed +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils.egg-info/dependency_links.txt +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils.egg-info/entry_points.txt +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/sqlite_utils.egg-info/top_level.txt +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/__init__.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_analyze.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_attach.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_cli_bulk.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_column_affinity.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_constructor.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_conversions.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_convert.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_create_view.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_delete.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_enable_counts.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_extracts.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_get.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_hypothesis.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_insert_files.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_list_mode.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_lookup.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_m2m.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_query.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_recipes.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_rows.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_sniff.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_suggest_column_types.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_update.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_upsert.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_utils.py +0 -0
- {sqlite_utils-4.0a1 → sqlite_utils-4.0rc1}/tests/test_wal.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: sqlite-utils
|
|
3
|
-
Version: 4.
|
|
3
|
+
Version: 4.0rc1
|
|
4
4
|
Summary: CLI tool and Python library for manipulating SQLite databases
|
|
5
5
|
Author: Simon Willison
|
|
6
6
|
License-Expression: Apache-2.0
|
|
@@ -22,34 +22,13 @@ Classifier: Topic :: Database
|
|
|
22
22
|
Requires-Python: >=3.10
|
|
23
23
|
Description-Content-Type: text/markdown
|
|
24
24
|
License-File: LICENSE
|
|
25
|
-
Requires-Dist: click
|
|
25
|
+
Requires-Dist: click>=8.3.1
|
|
26
26
|
Requires-Dist: click-default-group>=1.2.3
|
|
27
27
|
Requires-Dist: pluggy
|
|
28
28
|
Requires-Dist: python-dateutil
|
|
29
29
|
Requires-Dist: sqlite-fts4
|
|
30
30
|
Requires-Dist: tabulate
|
|
31
|
-
|
|
32
|
-
Requires-Dist: black>=24.1.1; extra == "test"
|
|
33
|
-
Requires-Dist: cogapp; extra == "test"
|
|
34
|
-
Requires-Dist: hypothesis; extra == "test"
|
|
35
|
-
Requires-Dist: pytest; extra == "test"
|
|
36
|
-
Provides-Extra: docs
|
|
37
|
-
Requires-Dist: beanbag-docutils>=2.0; extra == "docs"
|
|
38
|
-
Requires-Dist: codespell; extra == "docs"
|
|
39
|
-
Requires-Dist: furo; extra == "docs"
|
|
40
|
-
Requires-Dist: pygments-csv-lexer; extra == "docs"
|
|
41
|
-
Requires-Dist: sphinx-autobuild; extra == "docs"
|
|
42
|
-
Requires-Dist: sphinx-copybutton; extra == "docs"
|
|
43
|
-
Provides-Extra: mypy
|
|
44
|
-
Requires-Dist: data-science-types; extra == "mypy"
|
|
45
|
-
Requires-Dist: mypy; extra == "mypy"
|
|
46
|
-
Requires-Dist: types-click; extra == "mypy"
|
|
47
|
-
Requires-Dist: types-pluggy; extra == "mypy"
|
|
48
|
-
Requires-Dist: types-python-dateutil; extra == "mypy"
|
|
49
|
-
Requires-Dist: types-tabulate; extra == "mypy"
|
|
50
|
-
Provides-Extra: flake8
|
|
51
|
-
Requires-Dist: flake8; extra == "flake8"
|
|
52
|
-
Requires-Dist: flake8-pyproject; extra == "flake8"
|
|
31
|
+
Requires-Dist: pip
|
|
53
32
|
Dynamic: license-file
|
|
54
33
|
|
|
55
34
|
# sqlite-utils
|
|
@@ -4,6 +4,32 @@
|
|
|
4
4
|
Changelog
|
|
5
5
|
===========
|
|
6
6
|
|
|
7
|
+
.. _v4_0rc1:
|
|
8
|
+
|
|
9
|
+
4.0rc1 (2026-06-21)
|
|
10
|
+
-------------------
|
|
11
|
+
|
|
12
|
+
- New :ref:`database migrations system <migrations>`, incorporating functionality that was previously provided by the separate `sqlite-migrate <https://github.com/simonw/sqlite-migrate>`__ plugin. Define migration sets using the new :class:`sqlite_utils.Migrations` class and apply them using the ``sqlite-utils migrate`` command or the :ref:`migrations Python API <migrations_python>`. (:issue:`752`)
|
|
13
|
+
- New ``db.atomic()`` :ref:`context manager providing nested transaction support <python_api_atomic>` using SQLite transactions and savepoints. Internal multi-step operations such as ``table.transform()`` now use this mechanism to avoid unexpectedly committing an existing transaction. (:issue:`755`)
|
|
14
|
+
- ``Database`` objects can now be :ref:`used as context managers <python_api_close>`, automatically closing the connection when the ``with`` block exits. The CLI also now closes database and file handles more reliably, resolving a number of ``ResourceWarning`` warnings. (:issue:`692`)
|
|
15
|
+
- The ``sqlite-utils convert`` command can now accept a direct callable reference such as ``r.parsedate`` or ``json.loads --import json`` as the conversion code, as an alternative to calling it explicitly with ``r.parsedate(value)``. (:issue:`686`)
|
|
16
|
+
- Fixed a bug where CSV or TSV files with only a header row could crash ``sqlite-utils insert`` and ``sqlite-utils memory`` when type detection was enabled. Thanks, `Rami Abdelrazzaq <https://github.com/RamiNoodle733>`__. (:issue:`702`, `#707 <https://github.com/simonw/sqlite-utils/pull/707>`__)
|
|
17
|
+
- Fixed a bug where installed plugins could be loaded while running the test suite, despite the test-mode safeguard that disables plugin loading. Thanks, `Rami Abdelrazzaq <https://github.com/RamiNoodle733>`__. (:issue:`713`, `#719 <https://github.com/simonw/sqlite-utils/pull/719>`__)
|
|
18
|
+
- ``table.detect_fts()`` now recognizes legacy FTS virtual tables that quote the ``content=`` table name using square brackets, allowing ``table.enable_fts(..., replace=True)`` to replace them correctly. (:issue:`694`)
|
|
19
|
+
- Now depends on Click 8.3.1 or later, removing compatibility workarounds for Click's ``Sentinel`` default values. (:issue:`666`)
|
|
20
|
+
- Improved type annotations throughout the package, with ``ty`` now run in CI. (:issue:`697`)
|
|
21
|
+
- Development tooling now uses ``uv`` dependency groups, with separate ``dev`` and ``docs`` groups. (:issue:`691`)
|
|
22
|
+
- The test suite now runs against Python 3.15-dev. (:issue:`738`)
|
|
23
|
+
|
|
24
|
+
.. _v3_39:
|
|
25
|
+
|
|
26
|
+
3.39 (2025-11-24)
|
|
27
|
+
-----------------
|
|
28
|
+
|
|
29
|
+
- Fixed a bug with ``sqlite-utils install`` when the tool had been installed using ``uv``. (:issue:`687`)
|
|
30
|
+
- The ``--functions`` argument now optionally accepts a path to a Python file as an alternative to a string full of code, and can be specified multiple times - see :ref:`cli_query_functions`. (:issue:`659`)
|
|
31
|
+
- ``sqlite-utils`` now requires Python 3.10 or higher.
|
|
32
|
+
|
|
7
33
|
.. _v4_0a1:
|
|
8
34
|
|
|
9
35
|
4.0a1 (2025-11-23)
|
|
@@ -173,7 +199,7 @@ This release introduces a new :ref:`plugin system <plugins>`. Read more about th
|
|
|
173
199
|
- Conversion functions passed to :ref:`table.convert(...) <python_api_convert>` can now return lists or dictionaries, which will be inserted into the database as JSON strings. (:issue:`495`)
|
|
174
200
|
- ``sqlite-utils install`` and ``sqlite-utils uninstall`` commands for installing packages into the same virtual environment as ``sqlite-utils``, :ref:`described here <cli_install>`. (:issue:`483`)
|
|
175
201
|
- New :ref:`sqlite_utils.utils.flatten() <reference_utils_flatten>` utility function. (:issue:`500`)
|
|
176
|
-
- Documentation on :ref:`using Just <contributing_just>` to run tests, linters and build documentation.
|
|
202
|
+
- Documentation on :ref:`using Just <contributing_just>` to run tests, linters and build documentation.
|
|
177
203
|
- Documentation now covers the :ref:`release_process` for this package.
|
|
178
204
|
|
|
179
205
|
.. _v3_29:
|
|
@@ -20,7 +20,7 @@ This page lists the ``--help`` for every ``sqlite-utils`` CLI sub-command.
|
|
|
20
20
|
"query", "memory", "insert", "upsert", "bulk", "search", "transform", "extract",
|
|
21
21
|
"schema", "insert-files", "analyze-tables", "convert", "tables", "views", "rows",
|
|
22
22
|
"triggers", "indexes", "create-database", "create-table", "create-index",
|
|
23
|
-
"enable-fts", "populate-fts", "rebuild-fts", "disable-fts"
|
|
23
|
+
"migrate", "enable-fts", "populate-fts", "rebuild-fts", "disable-fts"
|
|
24
24
|
]
|
|
25
25
|
refs = {
|
|
26
26
|
"query": "cli_query",
|
|
@@ -49,6 +49,7 @@ This page lists the ``--help`` for every ``sqlite-utils`` CLI sub-command.
|
|
|
49
49
|
"enable-wal": "cli_wal",
|
|
50
50
|
"enable-counts": "cli_enable_counts",
|
|
51
51
|
"bulk": "cli_bulk",
|
|
52
|
+
"migrate": "cli_migrate",
|
|
52
53
|
"create-database": "cli_create_database",
|
|
53
54
|
"create-table": "cli_create_table",
|
|
54
55
|
"drop-table": "cli_drop_table",
|
|
@@ -117,15 +118,15 @@ See :ref:`cli_query`.
|
|
|
117
118
|
--tsv Output TSV
|
|
118
119
|
--no-headers Omit CSV headers
|
|
119
120
|
-t, --table Output as a formatted table
|
|
120
|
-
--fmt TEXT Table format - one of asciidoc,
|
|
121
|
-
double_outline, fancy_grid,
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
unsafehtml, youtrack
|
|
121
|
+
--fmt TEXT Table format - one of asciidoc, colon_grid,
|
|
122
|
+
double_grid, double_outline, fancy_grid,
|
|
123
|
+
fancy_outline, github, grid, heavy_grid,
|
|
124
|
+
heavy_outline, html, jira, latex, latex_booktabs,
|
|
125
|
+
latex_longtable, latex_raw, mediawiki, mixed_grid,
|
|
126
|
+
mixed_outline, moinmoin, orgtbl, outline, pipe,
|
|
127
|
+
plain, presto, pretty, psql, rounded_grid,
|
|
128
|
+
rounded_outline, rst, simple, simple_grid,
|
|
129
|
+
simple_outline, textile, tsv, unsafehtml, youtrack
|
|
129
130
|
--json-cols Detect JSON cols and output them as JSON, not
|
|
130
131
|
escaped strings
|
|
131
132
|
-r, --raw Raw output, first column of first row
|
|
@@ -186,15 +187,15 @@ See :ref:`cli_memory`.
|
|
|
186
187
|
--tsv Output TSV
|
|
187
188
|
--no-headers Omit CSV headers
|
|
188
189
|
-t, --table Output as a formatted table
|
|
189
|
-
--fmt TEXT Table format - one of asciidoc,
|
|
190
|
-
double_outline, fancy_grid,
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
unsafehtml, youtrack
|
|
190
|
+
--fmt TEXT Table format - one of asciidoc, colon_grid,
|
|
191
|
+
double_grid, double_outline, fancy_grid,
|
|
192
|
+
fancy_outline, github, grid, heavy_grid,
|
|
193
|
+
heavy_outline, html, jira, latex, latex_booktabs,
|
|
194
|
+
latex_longtable, latex_raw, mediawiki, mixed_grid,
|
|
195
|
+
mixed_outline, moinmoin, orgtbl, outline, pipe,
|
|
196
|
+
plain, presto, pretty, psql, rounded_grid,
|
|
197
|
+
rounded_outline, rst, simple, simple_grid,
|
|
198
|
+
simple_outline, textile, tsv, unsafehtml, youtrack
|
|
198
199
|
--json-cols Detect JSON cols and output them as JSON, not
|
|
199
200
|
escaped strings
|
|
200
201
|
-r, --raw Raw output, first column of first row
|
|
@@ -425,14 +426,15 @@ See :ref:`cli_search`.
|
|
|
425
426
|
--tsv Output TSV
|
|
426
427
|
--no-headers Omit CSV headers
|
|
427
428
|
-t, --table Output as a formatted table
|
|
428
|
-
--fmt TEXT Table format - one of asciidoc,
|
|
429
|
-
double_outline, fancy_grid, fancy_outline,
|
|
430
|
-
grid, heavy_grid, heavy_outline, html, jira,
|
|
431
|
-
latex_booktabs, latex_longtable, latex_raw,
|
|
432
|
-
mixed_grid, mixed_outline, moinmoin, orgtbl,
|
|
433
|
-
pipe, plain, presto, pretty, psql,
|
|
434
|
-
rounded_outline, rst, simple,
|
|
435
|
-
simple_outline, textile, tsv, unsafehtml,
|
|
429
|
+
--fmt TEXT Table format - one of asciidoc, colon_grid,
|
|
430
|
+
double_grid, double_outline, fancy_grid, fancy_outline,
|
|
431
|
+
github, grid, heavy_grid, heavy_outline, html, jira,
|
|
432
|
+
latex, latex_booktabs, latex_longtable, latex_raw,
|
|
433
|
+
mediawiki, mixed_grid, mixed_outline, moinmoin, orgtbl,
|
|
434
|
+
outline, pipe, plain, presto, pretty, psql,
|
|
435
|
+
rounded_grid, rounded_outline, rst, simple,
|
|
436
|
+
simple_grid, simple_outline, textile, tsv, unsafehtml,
|
|
437
|
+
youtrack
|
|
436
438
|
--json-cols Detect JSON cols and output them as JSON, not escaped
|
|
437
439
|
strings
|
|
438
440
|
--load-extension TEXT Path to SQLite extension, with optional :entrypoint
|
|
@@ -615,11 +617,13 @@ See :ref:`cli_convert`.
|
|
|
615
617
|
|
|
616
618
|
The following common operations are available as recipe functions:
|
|
617
619
|
|
|
618
|
-
r.jsonsplit(value, delimiter=',', type
|
|
620
|
+
r.jsonsplit(value: 'str', delimiter: 'str' = ',', type: 'Callable[[str],
|
|
621
|
+
object]' = <class 'str'>) -> 'str'
|
|
619
622
|
|
|
620
623
|
Convert a string like a,b,c into a JSON array ["a", "b", "c"]
|
|
621
624
|
|
|
622
|
-
r.parsedate(value, dayfirst=False, yearfirst=False,
|
|
625
|
+
r.parsedate(value: 'str', dayfirst: 'bool' = False, yearfirst: 'bool' = False,
|
|
626
|
+
errors: 'Optional[object]' = None) -> 'Optional[str]'
|
|
623
627
|
|
|
624
628
|
Parse a date and convert it to ISO date format: yyyy-mm-dd
|
|
625
629
|
|
|
@@ -628,7 +632,8 @@ See :ref:`cli_convert`.
|
|
|
628
632
|
- errors=r.IGNORE to ignore values that cannot be parsed
|
|
629
633
|
- errors=r.SET_NULL to set values that cannot be parsed to null
|
|
630
634
|
|
|
631
|
-
r.parsedatetime(value, dayfirst=False, yearfirst
|
|
635
|
+
r.parsedatetime(value: 'str', dayfirst: 'bool' = False, yearfirst: 'bool' =
|
|
636
|
+
False, errors: 'Optional[object]' = None) -> 'Optional[str]'
|
|
632
637
|
|
|
633
638
|
Parse a datetime and convert it to ISO datetime format: yyyy-mm-ddTHH:MM:SS
|
|
634
639
|
|
|
@@ -687,14 +692,15 @@ See :ref:`cli_tables`.
|
|
|
687
692
|
--tsv Output TSV
|
|
688
693
|
--no-headers Omit CSV headers
|
|
689
694
|
-t, --table Output as a formatted table
|
|
690
|
-
--fmt TEXT Table format - one of asciidoc,
|
|
691
|
-
double_outline, fancy_grid, fancy_outline,
|
|
692
|
-
grid, heavy_grid, heavy_outline, html, jira,
|
|
693
|
-
latex_booktabs, latex_longtable, latex_raw,
|
|
694
|
-
mixed_grid, mixed_outline, moinmoin, orgtbl,
|
|
695
|
-
pipe, plain, presto, pretty, psql,
|
|
696
|
-
rounded_outline, rst, simple,
|
|
697
|
-
simple_outline, textile, tsv, unsafehtml,
|
|
695
|
+
--fmt TEXT Table format - one of asciidoc, colon_grid,
|
|
696
|
+
double_grid, double_outline, fancy_grid, fancy_outline,
|
|
697
|
+
github, grid, heavy_grid, heavy_outline, html, jira,
|
|
698
|
+
latex, latex_booktabs, latex_longtable, latex_raw,
|
|
699
|
+
mediawiki, mixed_grid, mixed_outline, moinmoin, orgtbl,
|
|
700
|
+
outline, pipe, plain, presto, pretty, psql,
|
|
701
|
+
rounded_grid, rounded_outline, rst, simple,
|
|
702
|
+
simple_grid, simple_outline, textile, tsv, unsafehtml,
|
|
703
|
+
youtrack
|
|
698
704
|
--json-cols Detect JSON cols and output them as JSON, not escaped
|
|
699
705
|
strings
|
|
700
706
|
--columns Include list of columns for each table
|
|
@@ -728,14 +734,15 @@ See :ref:`cli_views`.
|
|
|
728
734
|
--tsv Output TSV
|
|
729
735
|
--no-headers Omit CSV headers
|
|
730
736
|
-t, --table Output as a formatted table
|
|
731
|
-
--fmt TEXT Table format - one of asciidoc,
|
|
732
|
-
double_outline, fancy_grid, fancy_outline,
|
|
733
|
-
grid, heavy_grid, heavy_outline, html, jira,
|
|
734
|
-
latex_booktabs, latex_longtable, latex_raw,
|
|
735
|
-
mixed_grid, mixed_outline, moinmoin, orgtbl,
|
|
736
|
-
pipe, plain, presto, pretty, psql,
|
|
737
|
-
rounded_outline, rst, simple,
|
|
738
|
-
simple_outline, textile, tsv, unsafehtml,
|
|
737
|
+
--fmt TEXT Table format - one of asciidoc, colon_grid,
|
|
738
|
+
double_grid, double_outline, fancy_grid, fancy_outline,
|
|
739
|
+
github, grid, heavy_grid, heavy_outline, html, jira,
|
|
740
|
+
latex, latex_booktabs, latex_longtable, latex_raw,
|
|
741
|
+
mediawiki, mixed_grid, mixed_outline, moinmoin, orgtbl,
|
|
742
|
+
outline, pipe, plain, presto, pretty, psql,
|
|
743
|
+
rounded_grid, rounded_outline, rst, simple,
|
|
744
|
+
simple_grid, simple_outline, textile, tsv, unsafehtml,
|
|
745
|
+
youtrack
|
|
739
746
|
--json-cols Detect JSON cols and output them as JSON, not escaped
|
|
740
747
|
strings
|
|
741
748
|
--columns Include list of columns for each view
|
|
@@ -774,15 +781,15 @@ See :ref:`cli_rows`.
|
|
|
774
781
|
--tsv Output TSV
|
|
775
782
|
--no-headers Omit CSV headers
|
|
776
783
|
-t, --table Output as a formatted table
|
|
777
|
-
--fmt TEXT Table format - one of asciidoc,
|
|
778
|
-
double_outline, fancy_grid,
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
unsafehtml, youtrack
|
|
784
|
+
--fmt TEXT Table format - one of asciidoc, colon_grid,
|
|
785
|
+
double_grid, double_outline, fancy_grid,
|
|
786
|
+
fancy_outline, github, grid, heavy_grid,
|
|
787
|
+
heavy_outline, html, jira, latex, latex_booktabs,
|
|
788
|
+
latex_longtable, latex_raw, mediawiki, mixed_grid,
|
|
789
|
+
mixed_outline, moinmoin, orgtbl, outline, pipe,
|
|
790
|
+
plain, presto, pretty, psql, rounded_grid,
|
|
791
|
+
rounded_outline, rst, simple, simple_grid,
|
|
792
|
+
simple_outline, textile, tsv, unsafehtml, youtrack
|
|
786
793
|
--json-cols Detect JSON cols and output them as JSON, not
|
|
787
794
|
escaped strings
|
|
788
795
|
--load-extension TEXT Path to SQLite extension, with optional
|
|
@@ -814,14 +821,15 @@ See :ref:`cli_triggers`.
|
|
|
814
821
|
--tsv Output TSV
|
|
815
822
|
--no-headers Omit CSV headers
|
|
816
823
|
-t, --table Output as a formatted table
|
|
817
|
-
--fmt TEXT Table format - one of asciidoc,
|
|
818
|
-
double_outline, fancy_grid, fancy_outline,
|
|
819
|
-
grid, heavy_grid, heavy_outline, html, jira,
|
|
820
|
-
latex_booktabs, latex_longtable, latex_raw,
|
|
821
|
-
mixed_grid, mixed_outline, moinmoin, orgtbl,
|
|
822
|
-
pipe, plain, presto, pretty, psql,
|
|
823
|
-
rounded_outline, rst, simple,
|
|
824
|
-
simple_outline, textile, tsv, unsafehtml,
|
|
824
|
+
--fmt TEXT Table format - one of asciidoc, colon_grid,
|
|
825
|
+
double_grid, double_outline, fancy_grid, fancy_outline,
|
|
826
|
+
github, grid, heavy_grid, heavy_outline, html, jira,
|
|
827
|
+
latex, latex_booktabs, latex_longtable, latex_raw,
|
|
828
|
+
mediawiki, mixed_grid, mixed_outline, moinmoin, orgtbl,
|
|
829
|
+
outline, pipe, plain, presto, pretty, psql,
|
|
830
|
+
rounded_grid, rounded_outline, rst, simple,
|
|
831
|
+
simple_grid, simple_outline, textile, tsv, unsafehtml,
|
|
832
|
+
youtrack
|
|
825
833
|
--json-cols Detect JSON cols and output them as JSON, not escaped
|
|
826
834
|
strings
|
|
827
835
|
--load-extension TEXT Path to SQLite extension, with optional :entrypoint
|
|
@@ -853,14 +861,15 @@ See :ref:`cli_indexes`.
|
|
|
853
861
|
--tsv Output TSV
|
|
854
862
|
--no-headers Omit CSV headers
|
|
855
863
|
-t, --table Output as a formatted table
|
|
856
|
-
--fmt TEXT Table format - one of asciidoc,
|
|
857
|
-
double_outline, fancy_grid, fancy_outline,
|
|
858
|
-
grid, heavy_grid, heavy_outline, html, jira,
|
|
859
|
-
latex_booktabs, latex_longtable, latex_raw,
|
|
860
|
-
mixed_grid, mixed_outline, moinmoin, orgtbl,
|
|
861
|
-
pipe, plain, presto, pretty, psql,
|
|
862
|
-
rounded_outline, rst, simple,
|
|
863
|
-
simple_outline, textile, tsv, unsafehtml,
|
|
864
|
+
--fmt TEXT Table format - one of asciidoc, colon_grid,
|
|
865
|
+
double_grid, double_outline, fancy_grid, fancy_outline,
|
|
866
|
+
github, grid, heavy_grid, heavy_outline, html, jira,
|
|
867
|
+
latex, latex_booktabs, latex_longtable, latex_raw,
|
|
868
|
+
mediawiki, mixed_grid, mixed_outline, moinmoin, orgtbl,
|
|
869
|
+
outline, pipe, plain, presto, pretty, psql,
|
|
870
|
+
rounded_grid, rounded_outline, rst, simple,
|
|
871
|
+
simple_grid, simple_outline, textile, tsv, unsafehtml,
|
|
872
|
+
youtrack
|
|
864
873
|
--json-cols Detect JSON cols and output them as JSON, not escaped
|
|
865
874
|
strings
|
|
866
875
|
--load-extension TEXT Path to SQLite extension, with optional :entrypoint
|
|
@@ -957,6 +966,44 @@ See :ref:`cli_create_index`.
|
|
|
957
966
|
-h, --help Show this message and exit.
|
|
958
967
|
|
|
959
968
|
|
|
969
|
+
.. _cli_ref_migrate:
|
|
970
|
+
|
|
971
|
+
migrate
|
|
972
|
+
=======
|
|
973
|
+
|
|
974
|
+
See :ref:`cli_migrate`.
|
|
975
|
+
|
|
976
|
+
::
|
|
977
|
+
|
|
978
|
+
Usage: sqlite-utils migrate [OPTIONS] DB_PATH [MIGRATIONS]...
|
|
979
|
+
|
|
980
|
+
Apply pending database migrations.
|
|
981
|
+
|
|
982
|
+
Usage:
|
|
983
|
+
|
|
984
|
+
sqlite-utils migrate database.db
|
|
985
|
+
|
|
986
|
+
This will find the migrations.py file in the current directory or
|
|
987
|
+
subdirectories and apply any pending migrations.
|
|
988
|
+
|
|
989
|
+
Or pass paths to one or more migrations.py files directly:
|
|
990
|
+
|
|
991
|
+
sqlite-utils migrate database.db path/to/migrations.py
|
|
992
|
+
|
|
993
|
+
Pass --list to see a list of applied and pending migrations without applying
|
|
994
|
+
them.
|
|
995
|
+
|
|
996
|
+
Use --stop-before migration_set:name to stop before a migration. This option
|
|
997
|
+
can be used multiple times.
|
|
998
|
+
|
|
999
|
+
Options:
|
|
1000
|
+
--stop-before TEXT Stop before applying this migration. Use set:name to
|
|
1001
|
+
target a migration set.
|
|
1002
|
+
--list List migrations without running them
|
|
1003
|
+
-v, --verbose Show verbose output
|
|
1004
|
+
-h, --help Show this message and exit.
|
|
1005
|
+
|
|
1006
|
+
|
|
960
1007
|
.. _cli_ref_enable_fts:
|
|
961
1008
|
|
|
962
1009
|
enable-fts
|
|
@@ -257,6 +257,7 @@ Available ``--fmt`` options are:
|
|
|
257
257
|
.. ]]]
|
|
258
258
|
|
|
259
259
|
- ``asciidoc``
|
|
260
|
+
- ``colon_grid``
|
|
260
261
|
- ``double_grid``
|
|
261
262
|
- ``double_outline``
|
|
262
263
|
- ``fancy_grid``
|
|
@@ -1057,6 +1058,37 @@ That will look for SpatiaLite in a set of predictable locations. To load it from
|
|
|
1057
1058
|
|
|
1058
1059
|
sqlite-utils create-database empty.db --init-spatialite --load-extension /path/to/spatialite.so
|
|
1059
1060
|
|
|
1061
|
+
.. _cli_migrate:
|
|
1062
|
+
|
|
1063
|
+
Running migrations
|
|
1064
|
+
==================
|
|
1065
|
+
|
|
1066
|
+
The ``migrate`` command applies pending Python migrations to a database. For the full migration file format and Python API, see :ref:`migrations`.
|
|
1067
|
+
|
|
1068
|
+
.. code-block:: bash
|
|
1069
|
+
|
|
1070
|
+
sqlite-utils migrate creatures.db path/to/migrations.py
|
|
1071
|
+
|
|
1072
|
+
If you omit the migration path it will search the current directory and subdirectories for files called ``migrations.py``:
|
|
1073
|
+
|
|
1074
|
+
.. code-block:: bash
|
|
1075
|
+
|
|
1076
|
+
sqlite-utils migrate creatures.db
|
|
1077
|
+
|
|
1078
|
+
Use ``--list`` to list applied and pending migrations without running them:
|
|
1079
|
+
|
|
1080
|
+
.. code-block:: bash
|
|
1081
|
+
|
|
1082
|
+
sqlite-utils migrate creatures.db --list
|
|
1083
|
+
|
|
1084
|
+
Use ``--stop-before`` to stop before a named migration. The option can be passed more than once, and can target a specific migration set using ``migration_set:migration_name``:
|
|
1085
|
+
|
|
1086
|
+
.. code-block:: bash
|
|
1087
|
+
|
|
1088
|
+
sqlite-utils migrate creatures.db path/to/migrations.py \
|
|
1089
|
+
--stop-before creatures:add_weight \
|
|
1090
|
+
--stop-before sales:drop_index
|
|
1091
|
+
|
|
1060
1092
|
.. _cli_inserting_data:
|
|
1061
1093
|
|
|
1062
1094
|
Inserting JSON data
|
|
@@ -1849,7 +1881,19 @@ These recipes can be used in the code passed to ``sqlite-utils convert`` like th
|
|
|
1849
1881
|
sqlite-utils convert my.db mytable mycolumn \
|
|
1850
1882
|
'r.jsonsplit(value)'
|
|
1851
1883
|
|
|
1852
|
-
|
|
1884
|
+
You can also pass the recipe function directly without the ``(value)`` part - sqlite-utils will detect that it is a callable and use it automatically:
|
|
1885
|
+
|
|
1886
|
+
.. code-block:: bash
|
|
1887
|
+
|
|
1888
|
+
sqlite-utils convert my.db mytable mycolumn r.parsedate
|
|
1889
|
+
|
|
1890
|
+
This shorter syntax works for any callable, including functions from imported modules:
|
|
1891
|
+
|
|
1892
|
+
.. code-block:: bash
|
|
1893
|
+
|
|
1894
|
+
sqlite-utils convert my.db mytable mycolumn json.loads --import json
|
|
1895
|
+
|
|
1896
|
+
To use any of the documented parameters, use the full function call syntax:
|
|
1853
1897
|
|
|
1854
1898
|
.. code-block:: bash
|
|
1855
1899
|
|
|
@@ -13,78 +13,61 @@ All improvements to the software should start with an issue. Read `How I build a
|
|
|
13
13
|
Obtaining the code
|
|
14
14
|
==================
|
|
15
15
|
|
|
16
|
-
To work on this library locally, first checkout the code
|
|
16
|
+
To work on this library locally, first checkout the code::
|
|
17
17
|
|
|
18
18
|
git clone git@github.com:simonw/sqlite-utils
|
|
19
19
|
cd sqlite-utils
|
|
20
|
-
python3 -mvenv venv
|
|
21
|
-
source venv/bin/activate
|
|
22
20
|
|
|
23
|
-
|
|
21
|
+
Use ``uv run`` to run the development version of the tool::
|
|
24
22
|
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
Within the virtual environment running ``sqlite-utils`` should run your locally editable version of the tool. You can use ``which sqlite-utils`` to confirm that you are running the version that lives in your virtual environment.
|
|
23
|
+
uv run sqlite-utils --help
|
|
28
24
|
|
|
29
25
|
.. _contributing_tests:
|
|
30
26
|
|
|
31
27
|
Running the tests
|
|
32
28
|
=================
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
pip install -e '.[test]'
|
|
30
|
+
Use ``uv run`` to run the tests::
|
|
37
31
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
pytest
|
|
32
|
+
uv run pytest
|
|
41
33
|
|
|
42
34
|
.. _contributing_docs:
|
|
43
35
|
|
|
44
36
|
Building the documentation
|
|
45
37
|
==========================
|
|
46
38
|
|
|
47
|
-
To build the documentation
|
|
48
|
-
|
|
49
|
-
pip install -e '.[docs]'
|
|
39
|
+
To build the documentation run this command::
|
|
50
40
|
|
|
51
|
-
|
|
41
|
+
uv run make livehtml --directory docs
|
|
52
42
|
|
|
53
|
-
|
|
54
|
-
make livehtml
|
|
43
|
+
This will start a server on port 8000 that will serve the documentation and live-reload any time you make an edit to a ``.rst`` file.
|
|
55
44
|
|
|
56
45
|
The `cog <https://github.com/nedbat/cog>`__ tool is used to maintain portions of the documentation. You can run it like so::
|
|
57
46
|
|
|
58
|
-
cog -r docs/*.rst
|
|
47
|
+
uv run cog -r docs/*.rst
|
|
59
48
|
|
|
60
49
|
.. _contributing_linting:
|
|
61
50
|
|
|
62
51
|
Linting and formatting
|
|
63
52
|
======================
|
|
64
53
|
|
|
65
|
-
``sqlite-utils`` uses `Black <https://black.readthedocs.io/>`__ for code formatting, and `flake8 <https://flake8.pycqa.org/>`__ and `mypy <https://mypy.readthedocs.io/>`__ for linting and type checking
|
|
54
|
+
``sqlite-utils`` uses `Black <https://black.readthedocs.io/>`__ for code formatting, and `flake8 <https://flake8.pycqa.org/>`__ and `mypy <https://mypy.readthedocs.io/>`__ for linting and type checking::
|
|
66
55
|
|
|
67
|
-
|
|
56
|
+
uv run black .
|
|
68
57
|
|
|
69
|
-
|
|
58
|
+
Linting tools can be run like this::
|
|
70
59
|
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
pip install -e '.[flake8,mypy]'
|
|
74
|
-
|
|
75
|
-
Both commands can then be run in the root of the project like this::
|
|
76
|
-
|
|
77
|
-
flake8
|
|
78
|
-
mypy sqlite_utils
|
|
60
|
+
uv run flake8
|
|
61
|
+
uv run mypy sqlite_utils
|
|
79
62
|
|
|
80
63
|
All three of these tools are run by our CI mechanism against every commit and pull request.
|
|
81
64
|
|
|
82
65
|
.. _contributing_just:
|
|
83
66
|
|
|
84
|
-
Using Just
|
|
85
|
-
|
|
67
|
+
Using Just
|
|
68
|
+
==========
|
|
86
69
|
|
|
87
|
-
If you install `Just <https://github.com/casey/just>`__
|
|
70
|
+
If you install `Just <https://github.com/casey/just>`__ you can use it to manage your local development environment.
|
|
88
71
|
|
|
89
72
|
To run all of the tests and linters::
|
|
90
73
|
|