def is_table_partitioned(conn, tbl_name):
    'Function to determine whether a table is partitioned.'
    with conn.cursor() as cursor:
        cursor.execute('SELECT EXISTS (SELECT 1\n                                           FROM pg_class\n                                           JOIN pg_partitioned_table\n                                                ON pg_partitioned_table.partrelid = pg_class.oid\n                                          WHERE pg_class.relname = %s)', [tbl_name])
        return cursor.fetchone().exists
Function to determine whether a table is partitioned.
def is_table_partitioned(conn, tbl_name):
    
    with conn.cursor() as cursor:
        cursor.execute('SELECT EXISTS (SELECT 1\n                                           FROM pg_class\n                                           JOIN pg_partitioned_table\n                                                ON pg_partitioned_table.partrelid = pg_class.oid\n                                          WHERE pg_class.relname = %s)', [tbl_name])
        return cursor.fetchone().exists