src/dirbs/utils.py
def table_invariants_list(conn, table_names, invariant_col_names):
    """
    Gets a list of tuples containing the values for common table invariant columns across a list table names.

    Arguments:
        conn: dirbs db connection object
        table_names: table names to return invariant columns for
        invariant_col_names: invariant column names to find
    Returns:
        list of invariant columns
    """
    if len(table_names) == 0:
        # Need to return an empty list to avoid doing an empty query and generating an error
        return []

    with conn.cursor() as cursor:
        table_queries = []
        for tblname in table_names:
            table_queries.append(sql.SQL("""SELECT * FROM (SELECT {0} FROM {1} LIMIT 1) {2}""")
                                 .format(sql.SQL(', ').join(map(sql.Identifier, invariant_col_names)),
                                         sql.Identifier(tblname),
                                         sql.Identifier('tmp_{0}'.format(tblname))))
        cursor.execute(sql.SQL(' UNION ALL ').join(table_queries))
        return cursor.fetchall()

    Gets a list of tuples containing the values for common table invariant columns across a list table names.

    Arguments:
        conn: dirbs db connection object
        table_names: table names to return invariant columns for
        invariant_col_names: invariant column names to find
    Returns:
        list of invariant columns
    
Gets a list of tuples containing the values for common table invariant columns across a list table names.
Gets a list of tuples containing the values for common table invariant columns across a list table names .
def table_invariants_list(conn, table_names, invariant_col_names):
    if len(table_names) == 0:
        return []
    with conn.cursor() as cursor:
        table_queries = []
        for tblname in table_names:
            table_queries.append(sql.SQL("""SELECT * FROM (SELECT {0} FROM {1} LIMIT 1) {2}""")
                                 .format(sql.SQL(', ').join(map(sql.Identifier, invariant_col_names)),
                                         sql.Identifier(tblname),
                                         sql.Identifier('tmp_{0}'.format(tblname))))
        cursor.execute(sql.SQL(' UNION ALL ').join(table_queries))
        return cursor.fetchall()
def table_invariants_list ( conn , table_names , invariant_col_names ) : if len ( table_names ) == 0 : return [ ] with conn . cursor ( ) as cursor : table_queries = [ ] for tblname in table_names : table_queries . append ( sql . SQL ( """SELECT * FROM (SELECT {0} FROM {1} LIMIT 1) {2}""" ) . format ( sql . SQL ( ', ' ) . join ( map ( sql . Identifier , invariant_col_names ) ) , sql . Identifier ( tblname ) , sql . Identifier ( 'tmp_{0}' . format ( tblname ) ) ) ) cursor . execute ( sql . SQL ( ' UNION ALL ' ) . join ( table_queries ) ) return cursor . fetchall ( )
Gets a list of tuples containing the values for common table invariant columns across a list table names.
Gets a list of tuples containing the values for common table invariant columns across a list table names .
"""
    Gets a list of tuples containing the values for common table invariant columns across a list table names.

    Arguments:
        conn: dirbs db connection object
        table_names: table names to return invariant columns for
        invariant_col_names: invariant column names to find
    Returns:
        list of invariant columns
    """ # Need to return an empty list to avoid doing an empty query and generating an error
list of invariant columns
list of invariant columns
conn
dirbs db connection object
dirbs db connection object
table_names
table names to return invariant columns for
table names to return invariant columns for
invariant_col_names
invariant column names to find
invariant column names to find