def dropSchemaIfExist(conn,schemaname): sql = "SELECT nspname FROM pg_catalog.pg_namespace WHERE nspname = '%s'" % schemaname dropsql = "DROP SCHEMA %s" % schemaname cursor=None try: cursor=dbconn.execSQL(conn,sql) numrows = cursor.rowcount if numrows == 1: cursor=dbconn.execSQL(conn,dropsql) else: raise CatalogError("more than one entry in pg_namespace for '%s'" % schemaname) except Exception as e: raise CatalogError("error dropping schema %s: %s" % (schemaname, str(e))) finally: if cursor: cursor.close() conn.commit()
def basicSQLExec(conn, sql): cursor = None try: cursor = dbconn.execSQL(conn, sql) rows = cursor.fetchall() return rows finally: if cursor: cursor.close()
def basicSQLExec(conn,sql): cursor=None try: cursor=dbconn.execSQL(conn,sql) rows=cursor.fetchall() return rows finally: if cursor: cursor.close()
def get_catalogtable_list(conn): sql = """SELECT schemaname || '.' || tablename FROM pg_tables WHERE schemaname = 'pg_catalog' """ cursor=None try: cursor=dbconn.execSQL(conn,sql) return cursor.fetchall() finally: if cursor: cursor.close()
def get_catalogtable_list(conn): sql = """SELECT schemaname || '.' || tablename FROM pg_tables WHERE schemaname = 'pg_catalog' """ cursor = None try: cursor = dbconn.execSQL(conn, sql) return cursor.fetchall() finally: if cursor: cursor.close()
def get_standby_filespace_map(conn): """Returns an array of [fsname, fspath] arrays that represents all the filespaces on the standby master.""" sql = """SELECT fsname, fselocation FROM pg_filespace, pg_filespace_entry WHERE pg_filespace.oid = pg_filespace_entry.fsefsoid AND fsedbid = (SELECT MAX(dbid) FROM gp_segment_configuration)""" cursor = None try: cursor = dbconn.execSQL(conn, sql) return cursor.fetchall() finally: if cursor: cursor.close()
def doesSchemaExist(conn,schemaname): sql = "SELECT nspname FROM pg_catalog.pg_namespace WHERE nspname = '%s'" % schemaname cursor=None try: cursor=dbconn.execSQL(conn,sql) numrows = cursor.rowcount if numrows == 0: return False elif numrows == 1: return True else: raise CatalogError("more than one entry in pg_namespace for '%s'" % schemaname) finally: if cursor: cursor.close()