Skip to content

Commit

Permalink
Re-enable GeoPackage schemas checks
Browse files Browse the repository at this point in the history
  • Loading branch information
pjrule committed Apr 27, 2023
1 parent ba0de33 commit 87bf4cf
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions gerrydb/repos/view.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,17 +110,16 @@ def from_gpkg(cls, path: Path) -> "View":
"""Loads a view from a GeoPackage."""
conn = sqlite3.connect(path)

# TODO: Disabled for Colab demo -- reenable.
# tables = conn.execute(
# "SELECT name FROM sqlite_master WHERE "
# "type ='table' AND name NOT LIKE 'sqlite_%'"
# ).fetchall()
# missing_tables = _EXPECTED_TABLES - set(table[0] for table in tables)
# if missing_tables:
# raise ViewLoadError(
# "Cannot load view. Does the GeoPackage have GerryDB "
# f"extensions? (missing table(s): {', '.join(missing_tables)})"
# )
tables = conn.execute(
"SELECT name FROM sqlite_master WHERE "
"type ='table' AND name NOT LIKE 'sqlite_%'"
).fetchall()
missing_tables = _EXPECTED_TABLES - set(table[0] for table in tables)
if missing_tables:
raise ViewLoadError(
"Cannot load view. Does the GeoPackage have GerryDB "
f"extensions? (missing table(s): {', '.join(missing_tables)})"
)

meta_rows = conn.execute("SELECT key, value FROM gerrydb_view_meta").fetchall()
raw_meta = {row[0]: json.loads(row[1]) for row in meta_rows}
Expand Down

0 comments on commit 87bf4cf

Please sign in to comment.