mirror of
https://github.com/simonw/datasette.git
synced 2025-12-10 16:51:24 +01:00
Refactored run_sanity_checks to check_connection(conn), refs #674
This commit is contained in:
parent
f1442a8151
commit
d3f2fade88
4 changed files with 60 additions and 21 deletions
|
|
@ -216,26 +216,6 @@ class Datasette:
|
|||
def remove_database(self, name):
|
||||
self.databases.pop(name)
|
||||
|
||||
async def run_sanity_checks(self):
|
||||
# Only one check right now, for Spatialite
|
||||
for database_name, database in self.databases.items():
|
||||
# Run pragma_info on every table
|
||||
for table in await database.table_names():
|
||||
try:
|
||||
await self.execute(
|
||||
database_name,
|
||||
"PRAGMA table_info({});".format(escape_sqlite(table)),
|
||||
)
|
||||
except sqlite3.OperationalError as e:
|
||||
if e.args[0] == "no such module: VirtualSpatialIndex":
|
||||
raise click.UsageError(
|
||||
"It looks like you're trying to load a SpatiaLite"
|
||||
" database without first loading the SpatiaLite module."
|
||||
"\n\nRead more: https://datasette.readthedocs.io/en/latest/spatialite.html"
|
||||
)
|
||||
else:
|
||||
raise
|
||||
|
||||
def config(self, key):
|
||||
return self._config.get(key, None)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue