What to do if extensions will not load, refs #1979

0.63.x
Simon Willison 2023-01-07 15:48:08 -08:00
rodzic 1ec9c9995c
commit 3b88ac671e
1 zmienionych plików z 57 dodań i 0 usunięć

Wyświetl plik

@ -230,3 +230,60 @@ Some plugins such as `datasette-ripgrep <https://datasette.io/plugins/datasette-
pip install datasette-ripgrep'
docker commit $(docker ps -lq) datasette-with-ripgrep
.. _installation_extensions:
A note about extensions
=======================
SQLite supports extensions, such as :ref:`spatialite` for geospatial operations.
These can be loaded using the ``--load-extension`` argument, like so::
datasette --load-extension=/usr/local/lib/mod_spatialite.dylib
Some Python installations do not include support for SQLite extensions. If this is the case you will see the following error when you attempt to load an extension:
Your Python installation does not have the ability to load SQLite extensions.
In some cases you may see the following error message instead::
AttributeError: 'sqlite3.Connection' object has no attribute 'enable_load_extension'
On macOS the easiest fix for this is to install Datasette using Homebrew::
brew install datasette
Use ``which datasette`` to confirm that ``datasette`` will run that version. The output should look something like this::
/usr/local/opt/datasette/bin/datasette
If you get a different location here such as ``/Library/Frameworks/Python.framework/Versions/3.10/bin/datasette`` you can run the following command to cause ``datasette`` to execute the Homebrew version instead::
alias datasette=$(echo $(brew --prefix datasette)/bin/datasette)
You can undo this operation using::
unalias datasette
If you need to run SQLite with extension support for other Python code, you can do so by install Python itself using Homebrew::
brew install python
Then executing Python using::
/usr/local/opt/python@3/libexec/bin/python
A more convenient way to work with this version of Python may be to use it to create a virtual environment::
/usr/local/opt/python@3/libexec/bin/python -m venv datasette-venv
Then activate it like this::
source datasette-venv/bin/activate
Now running ``python`` and ``pip`` will work against a version of Python 3 that includes support for SQLite extensions::
pip install datasette
which datasette
datasette --version