def delete_from_postgis(resource_name):
 import psycopg2
 db = ogc_server_settings.datastore_db
 conn = None
 port = str(db['PORT'])
 try:
  conn = psycopg2.connect((((((((((("dbname='" + db['NAME']) + "' user='") + db['USER']) + "'  password='") + db['PASSWORD']) + "' port=") + port) + " host='") + db['HOST']) + "'"))
  cur = conn.cursor()
  cur.execute(("SELECT DropGeometryTable ('%s')" % resource_name))
  conn.commit()
 except Exception as e:
  logger.error('Error deleting PostGIS table %s:%s', resource_name, str(e))
 finally:
  try:
   if conn:
    conn.close()
  except Exception as e:
   logger.error('Error closing PostGIS conn %s:%s', resource_name, str(e))

def delete_from_postgis ( resource_name ) : import psycopg2 db = ogc_server_settings . datastore_db conn = None port = str ( db [ 'PORT' ] ) try : conn = psycopg2 . connect ( ( ( ( ( ( ( ( ( ( ( "dbname='" + db [ 'NAME' ] ) + "' user='" ) + db [ 'USER' ] ) + "'  password='" ) + db [ 'PASSWORD' ] ) + "' port=" ) + port ) + " host='" ) + db [ 'HOST' ] ) + "'" ) ) cur = conn . cursor ( ) cur . execute ( ( "SELECT DropGeometryTable ('%s')" % resource_name ) ) conn . commit ( ) except Exception as e : logger . error ( 'Error deleting PostGIS table %s:%s' , resource_name , str ( e ) ) finally : try : if conn : conn . close ( ) except Exception as e : logger . error ( 'Error closing PostGIS conn %s:%s' , resource_name , str ( e ) )
delete a table from postgis ; to be used after deleting a layer from the system .