Skip to content
New issue

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? Sign in to your account

--load-extension option for sqlite-utils query #134

Closed
simonw opened this issue Aug 21, 2020 · 4 comments
Closed

--load-extension option for sqlite-utils query #134

simonw opened this issue Aug 21, 2020 · 4 comments
Labels
enhancement New feature or request

Comments

@simonw
Copy link
Owner

simonw commented Aug 21, 2020

I got this error:

% sqlite-utils calands.db 'create table superunits_with_maps_view_concrete as select * from superunits_with_maps_view'
Traceback (most recent call last):
...
    cursor = db.conn.execute(sql, dict(param))
sqlite3.OperationalError: no such function: AsGeoJSON

A --load-extension=/usr/local/lib/mod_spatialite.dylib option (imitating the same option for Datasette) would help.

@simonw simonw added the enhancement New feature or request label Aug 21, 2020
@simonw
Copy link
Owner Author

simonw commented Aug 21, 2020

Trickiest part of this is how to write a test for it.

I'll do a pytest.skipIf that only executes the test if SpatiaLite is available.

@simonw
Copy link
Owner Author

simonw commented Aug 21, 2020

This should get me SpatiaLite in the GitHub Actions Ubuntu:

apt install libsqlite3-mod-spatialite

@simonw
Copy link
Owner Author

simonw commented Aug 21, 2020

I think that adds it as /usr/lib/x86_64-linux-gnu/mod_spatialite.so.

@simonw
Copy link
Owner Author

simonw commented Aug 21, 2020

Ended up needing two skipIfs:

@pytest.mark.skipif(not find_spatialite(), reason="Could not find SpatiaLite extension")
@pytest.mark.skipif(
not hasattr(sqlite3.Connection, "enable_load_extension"),
reason="sqlite3.Connection missing enable_load_extension",
)
def test_query_load_extension():

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant