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

SpatiaLite error could suggest --load-extension=spatialite #1115

Closed
simonw opened this issue Nov 29, 2020 · 1 comment
Closed

SpatiaLite error could suggest --load-extension=spatialite #1115

simonw opened this issue Nov 29, 2020 · 1 comment

Comments

@simonw
Copy link
Owner

simonw commented Nov 29, 2020

datasette/datasette/cli.py

Lines 533 to 548 in 242bc89

async def check_databases(ds):
# Run check_connection against every connected database
# to confirm they are all usable
for database in list(ds.databases.values()):
try:
await database.execute_fn(check_connection)
except SpatialiteConnectionProblem:
raise click.UsageError(
"It looks like you're trying to load a SpatiaLite"
" database without first loading the SpatiaLite module."
"\n\nRead more: https://docs.datasette.io/en/stable/spatialite.html"
)
except ConnectionProblem as e:
raise click.UsageError(
f"Connection to {database.path} failed check: {str(e.args[0])}"
)

This could use the find_spatialite() function and, if it finds something, suggest the user use --load-extension=spatialite

def find_spatialite():
for path in SPATIALITE_PATHS:
if os.path.exists(path):
return path
raise SpatialiteNotFound

@simonw
Copy link
Owner Author

simonw commented Nov 29, 2020

$ datasette ../shapefile-to-sqlite/nps-spatialite.db
Usage: datasette serve [OPTIONS] [FILES]...

Error: It looks like you're trying to load a SpatiaLite database without first loading the SpatiaLite module.

Try adding the --load-extension=spatialite option.

Read more: https://docs.datasette.io/en/stable/spatialite.html

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

No branches or pull requests

1 participant