예제 #1
0
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()
예제 #2
0
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()
예제 #3
0
파일: catalog.py 프로젝트: dbiir/T-SQL
def basicSQLExec(conn, sql):
    cursor = None
    try:
        cursor = dbconn.execSQL(conn, sql)
        rows = cursor.fetchall()
        return rows
    finally:
        if cursor:
            cursor.close()
예제 #4
0
def basicSQLExec(conn,sql):
    cursor=None
    try:
        cursor=dbconn.execSQL(conn,sql)
        rows=cursor.fetchall()
        return rows
    finally:
        if cursor:
            cursor.close()
예제 #5
0
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()
예제 #6
0
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()
예제 #7
0
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()
예제 #8
0
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()
예제 #9
0
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()
예제 #10
0
파일: catalog.py 프로젝트: xiehechong/hawq
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()