From 8fc1261c1befc1363c4abd4e311a9574b24858fb Mon Sep 17 00:00:00 2001 From: Rajat Venkatesh Date: Fri, 29 Mar 2019 11:09:00 +0530 Subject: [PATCH] fix:dev:Get catalog query through overridden method --- piicatcher/dbexplorer.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/piicatcher/dbexplorer.py b/piicatcher/dbexplorer.py index 32389cc..c8323f0 100644 --- a/piicatcher/dbexplorer.py +++ b/piicatcher/dbexplorer.py @@ -143,16 +143,20 @@ def get_columns(self, schema_name, table_name): return columns -class CachedExplorer(Explorer): +class CachedExplorer(Explorer, ABC): def __init__(self): super(CachedExplorer, self).__init__("") self._cache_ts = None + @abstractmethod + def _get_catalog_query(self): + pass + def _load_catalog(self): if self._cache_ts is None or self._cache_ts < datetime.now() - timedelta(minutes=10): with self.get_connection().cursor() as cursor: - cursor.execute(self._catalog_query) + cursor.execute(self._get_catalog_query()) self._schemas = [] row = cursor.fetchone() @@ -224,6 +228,9 @@ def _open_connection(self): user=self.user, password=self.password) + def _get_catalog_query(self): + return self._catalog_query + class PostgreSQLExplorer(CachedExplorer): _catalog_query = """ @@ -247,3 +254,5 @@ def _open_connection(self): password=self.password, database=self.database) + def _get_catalog_query(self): + return self._catalog_query