def drop_leaked_schemas(self, db_connection): leaked_schemas = self.__get_leaked_schemas(db_connection) for leaked_schema in leaked_schemas: escaped_schema_name = escapeDoubleQuoteInSQLString(leaked_schema) db_connection.query('DROP SCHEMA IF EXISTS %s CASCADE;' % (escaped_schema_name)) return leaked_schemas
def __init__(self, catalog_table_obj, issues, pk_name): self.catalog_table_obj = catalog_table_obj catalog_name = self.catalog_table_obj.getTableName() self._escaped_catalog_name = escapeDoubleQuoteInSQLString(catalog_name) self._issues = issues self._pk_name = pk_name
def _generate_delete_sql_for_oid(self, pk_name, oids): escaped_pk_name = escapeDoubleQuoteInSQLString(pk_name) delete_sql = 'BEGIN;set allow_system_table_mods=true;delete from {0} where {1} in ({2});COMMIT;' return delete_sql.format(self._escaped_catalog_name, escaped_pk_name, ','.join(str(oid) for oid in oids))