Contorto per non usare Python:
psql -d joomla -U joomla -h localhost --tuples-only <<EOF | dot -Tsvg -o usergroups.svg
SELECT text FROM (
SELECT 0 AS line, 'digraph usergroups {' AS text
UNION
SELECT 1, Concat(parent_id, '->', id, ';') FROM vvpi1_usergroups WHERE parent_id<>0
UNION
SELECT 1, Concat(id, '[label="', title, '"];') FROM vvpi1_usergroups
UNION
SELECT 2 AS line, '}'
) AS t
ORDER BY line;
EOF
Risultato: