install and uninstall commands, closes #483

This commit is contained in:
Simon Willison 2022-09-26 11:57:11 -07:00
commit 85247038f7
3 changed files with 89 additions and 0 deletions

View file

@ -59,6 +59,8 @@ This page lists the ``--help`` for every ``sqlite-utils`` CLI sub-command.
"convert": "cli_convert",
"add-geometry-column": "cli_spatialite",
"create-spatial-index": "cli_spatialite_indexes",
"install": "cli_install",
"uninstall": "cli_uninstall",
}
commands.sort(key = lambda command: go_first.index(command) if command in go_first else 999)
cog.out("\n")
@ -1349,6 +1351,42 @@ See :ref:`cli_drop_view`.
-h, --help Show this message and exit.
.. _cli_ref_install:
install
=======
See :ref:`cli_install`.
::
Usage: sqlite-utils install [OPTIONS] PACKAGES...
Install packages from PyPI into the same environment as sqlite-utils
Options:
-U, --upgrade Upgrade packages to latest version
-h, --help Show this message and exit.
.. _cli_ref_uninstall:
uninstall
=========
See :ref:`cli_uninstall`.
::
Usage: sqlite-utils uninstall [OPTIONS] PACKAGES...
Uninstall Python packages from the sqlite-utils environment
Options:
-y, --yes Don't ask for confirmation
-h, --help Show this message and exit.
.. _cli_ref_add_geometry_column:
add-geometry-column

View file

@ -2116,3 +2116,29 @@ Once you have a geometry column, you can speed up bounding box queries by adding
$ sqlite-utils create-spatial-index spatial.db locations geometry
See this `SpatiaLite Cookbook recipe <http://www.gaia-gis.it/gaia-sins/spatialite-cookbook-5/cookbook_topics.03.html#topic_Wonderful_RTree_Spatial_Index>`__ for examples of how to use a spatial index.
.. _cli_install:
Installing packages
-------------------
The :ref:`insert -\\-convert <cli_insert_convert>` and :ref:`query -\\-functions <cli_query_functions>` options can be provided with a Python script that imports additional modules from the ``sqlite-utils`` environment.
You can install packages from PyPI directly into the correct environment using ``sqlite-utils install <package>``. This is a wrapper around ``pip install``.
::
$ sqlite-utils install beautifulsoup4
Use ``-U`` to upgrade an existing package.
.. _cli_uninstall:
Uninstalling packages
---------------------
You can uninstall packages that were installed using ``sqlite-utils install`` with ``sqlite-utils uninstall <package>``::
$ sqlite-utils uninstall beautifulsoup4
Use ``-y`` to skip the request for confirmation.