Skip to content

Commit 8eb1e38

Browse files
omadpjonsson
authored andcommitted
Move schema_initialized() into common parent class
1 parent 0d91758 commit 8eb1e38

File tree

3 files changed

+4
-20
lines changed

3 files changed

+4
-20
lines changed

cubedash/index/api.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@
77
from datacube.index import Index
88
from datacube.model import Dataset, MetadataType, Product, Range
99
from datacube.model.fields import Field
10-
from sqlalchemy import CursorResult, Result, Row, Select
10+
from sqlalchemy import CursorResult, Result, Row, Select, inspect
1111
from sqlalchemy.sql import ColumnElement
1212
from sqlalchemy.sql.elements import ClauseElement, Label
1313

14-
from cubedash.summary._schema import PleaseRefresh
14+
from cubedash.summary._schema import CUBEDASH_SCHEMA, PleaseRefresh
1515

1616

1717
class EmptyDbError(Exception):
@@ -215,8 +215,8 @@ def spatial_select_query(
215215
@abstractmethod
216216
def select_spatial_stats(self) -> Result: ...
217217

218-
@abstractmethod
219-
def schema_initialised(self) -> bool: ...
218+
def schema_initialised(self) -> bool:
219+
return inspect(self.engine).has_schema(CUBEDASH_SCHEMA)
220220

221221
@abstractmethod
222222
def schema_compatible_info(

cubedash/index/postgis/_api.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -815,14 +815,6 @@ def select_spatial_stats(self):
815815
)
816816
)
817817

818-
@override
819-
def schema_initialised(self) -> bool:
820-
"""
821-
Do our DB schemas exist?
822-
"""
823-
with self.engine.begin() as conn:
824-
return _schema.has_schema(conn)
825-
826818
@override
827819
def schema_compatible_info(self, for_writing_operations_too=False):
828820
"""

cubedash/index/postgres/_api.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -881,14 +881,6 @@ def select_spatial_stats(self):
881881
)
882882
)
883883

884-
@override
885-
def schema_initialised(self) -> bool:
886-
"""
887-
Do our DB schemas exist?
888-
"""
889-
with self.engine.begin() as conn:
890-
return _schema.has_schema(conn)
891-
892884
@override
893885
def schema_compatible_info(
894886
self, for_writing_operations_too=False

0 commit comments

Comments
 (0)