def child_table_names(conn, parent_name):
    'Return a list of table names for a parent table name.'
    with conn.cursor() as cursor:
        cursor.execute('SELECT c.relname AS child_tblname\n                            FROM pg_inherits\n                            JOIN pg_class AS c\n                                 ON (c.oid = inhrelid)\n                            JOIN pg_class AS p\n                                 ON (p.oid = inhparent)\n                            JOIN pg_catalog.pg_namespace nc\n                                 ON nc.oid = c.relnamespace\n                            JOIN pg_catalog.pg_namespace np\n                                 ON np.oid = p.relnamespace\n                           WHERE p.relname = %s\n                             AND np.nspname = current_schema()\n                             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.
def child_table_names(conn, parent_name):
    
    with conn.cursor() as cursor:
        cursor.execute('SELECT c.relname AS child_tblname\n                            FROM pg_inherits\n                            JOIN pg_class AS c\n                                 ON (c.oid = inhrelid)\n                            JOIN pg_class AS p\n                                 ON (p.oid = inhparent)\n                            JOIN pg_catalog.pg_namespace nc\n                                 ON nc.oid = c.relnamespace\n                            JOIN pg_catalog.pg_namespace np\n                                 ON np.oid = p.relnamespace\n                           WHERE p.relname = %s\n                             AND np.nspname = current_schema()\n                             AND nc.nspname = current_schema()', [parent_name])
        return [res.child_tblname for res in cursor]