Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and
privacy statement. We’ll occasionally send you account related emails.
Already on GitHub?
to your account
This would allow users with extra SQLite extensions installed (like spatialite) to load them at runtime.
Inspired by this comment: #46 (comment)
The text was updated successfully, but these errors were encountered:
Added --load-extension argument to datasette serve
Allows loading of SQLite extensions. Refs #110.
Here's how I tested this.
First I downloaded and started a docker container using https://hub.docker.com/r/prolocutor/python3-sqlite-ext - which includes the compiled spatialite extension. This downloads it, then starts a shell in that container.
docker run -it -p 8018:8018 prolocutor/python3-sqlite-ext:3.5.1-spatialite /bin/sh
Installed a pre-release build of datasette which includes the new --load-extension option.
pip install https://static.simonwillison.net/static/2017/datasette-0.13-py3-none-any.whl
Now grab a sample database from https://www.gaia-gis.it/spatialite-2.3.1/resources.html - and unzip and rename it (datasette doesn't yet like databases with dots in their filename):
mv test-2.3.sqlite test23.sqlite
Now start datasette on port 8018 (the port I exposed earlier) with the extension loaded:
datasette test23.sqlite -p 8018 -h 0.0.0.0 --load-extension /usr/local/lib/mod_spatialite.so
Now I can confirm that it worked:
If I run datasette without --load-extension I get this:
datasette test23.sqlite -p 8018 -h 0.0.0.0
Sorry, something went wrong.
To finish up, I committed the image I created in the above so I can run it again in the future:
docker commit $(docker ps -lq) datasette-sqlite
Now I can run it like this:
docker run -it -p 8018:8018 datasette-sqlite datasette /tmp/test23.sqlite -p 8018 -h 0.0.0.0 --load-extension /usr/local/lib/mod_spatialite.so
No branches or pull requests