src/dirbs/utils.py
def child_table_names(conn, parent_name):
    """
    Return a list of table names for a parent table name.

    Arguments:
        conn: dirbs db connection object
        parent_name: parent table name to get names of child tables
    Returns:
        list of child table names
    """
    with conn.cursor() as cursor:
        cursor.execute("""SELECT c.relname AS child_tblname
                            FROM pg_inherits
                            JOIN pg_class AS c
                                 ON (c.oid = inhrelid)
                            JOIN pg_class AS p
                                 ON (p.oid = inhparent)
                            JOIN pg_catalog.pg_namespace nc
                                 ON nc.oid = c.relnamespace
                            JOIN pg_catalog.pg_namespace np
                                 ON np.oid = p.relnamespace
                           WHERE p.relname = %s
                             AND np.nspname = current_schema()
                             AND nc.nspname = current_schema()""",
                       [parent_name])
        return [res.child_tblname for res in cursor]

    Return a list of table names for a parent table name.

    Arguments:
        conn: dirbs db connection object
        parent_name: parent table name to get names of child tables
    Returns:
        list of child table names
    
Return a list of table names for a parent table name.
Return a list of table names for a parent table name .
def child_table_names(conn, parent_name):
    with conn.cursor() as cursor:
        cursor.execute("""SELECT c.relname AS child_tblname
                            FROM pg_inherits
                            JOIN pg_class AS c
                                 ON (c.oid = inhrelid)
                            JOIN pg_class AS p
                                 ON (p.oid = inhparent)
                            JOIN pg_catalog.pg_namespace nc
                                 ON nc.oid = c.relnamespace
                            JOIN pg_catalog.pg_namespace np
                                 ON np.oid = p.relnamespace
                           WHERE p.relname = %s
                             AND np.nspname = current_schema()
                             AND nc.nspname = current_schema()""",
                       [parent_name])
        return [res.child_tblname for res in cursor]
def child_table_names ( conn , parent_name ) : with conn . cursor ( ) as cursor : cursor . execute ( """SELECT c.relname AS child_tblname
                            FROM pg_inherits
                            JOIN pg_class AS c
                                 ON (c.oid = inhrelid)
                            JOIN pg_class AS p
                                 ON (p.oid = inhparent)
                            JOIN pg_catalog.pg_namespace nc
                                 ON nc.oid = c.relnamespace
                            JOIN pg_catalog.pg_namespace np
                                 ON np.oid = p.relnamespace
                           WHERE p.relname = %s
                             AND np.nspname = current_schema()
                             AND nc.nspname = current_schema()""" , [ parent_name ] ) return [ res . child_tblname for res in cursor ]
Return a list of table names for a parent table name.
Return a list of table names for a parent table name .
"""
    Return a list of table names for a parent table name.

    Arguments:
        conn: dirbs db connection object
        parent_name: parent table name to get names of child tables
    Returns:
        list of child table names
    """
list of child table names
list of child table names
conn
dirbs db connection object
dirbs db connection object
parent_name
parent table name to get names of child tables
parent table name to get names of child tables