Skip to content

Commit

Permalink
Modify query to identify if db is postgis_sde_rds
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander-M-Waldman committed Apr 19, 2024
1 parent ee433c2 commit 2840ea0
Showing 1 changed file with 5 additions and 9 deletions.
14 changes: 5 additions & 9 deletions geopetl/postgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,25 +237,21 @@ def is_postgis_enabled(self):
self._is_postgis_enabled = False
return self._is_postgis_enabled


@property
def is_postgis_sde_rds(self):
# Get the value
if self._is_postgis_sde_rds is not None:
return self._is_postgis_sde_rds
# Set the value only once (saves on db calls)
stmt = '''select case when exists is true then 1 else 0 end as is_Rds from (
SELECT exists (
SELECT FROM information_schema.tables
WHERE table_schema = 'sde'
AND table_name = 'st_geometry_columns'
)
) foo;'''
stmt = '''select * from pg_roles where rolname like '%rds%' '''
self.cursor.execute(stmt)
result = self.cursor.fetchall()
if result == 0 and self.is_postgis_enabled and self.is_sde_enabled:
# if result == 0 and self.is_postgis_enabled and self.is_sde_enabled:
if result and self.is_postgis_enabled and self.is_sde_enabled:
self._is_postgis_sde_rds = True
else:
self._is_postgis_sde_rds = False
print(f'Is postgis sde rds? {self._is_postgis_sde_rds}')
return self._is_postgis_sde_rds


Expand Down

0 comments on commit 2840ea0

Please sign in to comment.