with psycopg2.connect(DSN) as connection:
    with connection.cursor() as cursor:
        cursor.execute(
            "select column_name from information_schema.columns where table_schema = 'YOUR_SCHEMA_NAME' and table_name='YOUR_TABLE_NAME'"
            )
column_names = [row[0] for row in cursor]
print('Column names: {}\n'.format(column_names))
Как получить список имен столбцов из курсора psycopg2?