Python Сырое рекурсивное преобразование запросов
cursor.execute("WITH recursive subordinates AS (SELECT 1 as id FROM NODES WHERE node_id ='" + str(document_node_edit) + "' UNION ALL SELECT e.* FROM NODES e INNER JOIN subordinates s ON s.parent_node::text = e.node_id::text)SELECT s.short_code, s.node_type FROM subordinates s where s.location_id='"" + str(location) + "' and s.node_type=1")