Skip to content

Instantly share code, notes, and snippets.

@simonw
Created December 27, 2024 01:31
Show Gist options
  • Save simonw/3bf5ff0ed3b47aefbb94d3fd992f81f9 to your computer and use it in GitHub Desktop.
Save simonw/3bf5ff0ed3b47aefbb94d3fd992f81f9 to your computer and use it in GitHub Desktop.

llama3.2:3b

Prompt

How do I use SpatiaLite with Datasette?

Attachment

https://github.com/simonw/datasette/blob/72f8ac680aab220efbc10fc7cc24d9040869e1a1/docs/spatialite.rst

Response

To use SpatiaLite with Datasette, you need to install the mod_spatialite dynamic library. This can then be loaded into Datasette using the --load-extension command-line option.

You can install it on OS X by running brew update and then brew install spatialite-tools. On Linux, SpatiaLite is packaged for most distributions, so you can typically install it with a package manager like apt.

When running Datasette, you can look for SpatiaLite in common installation locations or specify the full path to the extension if it's installed elsewhere.

For example, on OS X, you might run datasette --load-extension=spatialite after installing it with Homebrew. On Linux, you could use datasette --load-extension=/usr/lib/x86_64-linux-gnu/mod_spatialite.so.

It's also important to note that SpatiaLite adds a large number of additional SQL functions, some of which are not safe for untrusted users to execute. To secure your Datasette instance, consider disabling arbitrary SQL queries and defining canned queries with the SQL queries that use SpatiaLite functions you want people to be able to execute.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment