This is quite interesting! I’ve recently integrated SWI-Prolog as an extension for Postgres (see my PR to the Omnigres repo). It has a rudimentary query/3 primitive, and while it has some nice features like unifying columns by name and/or index, I keep thinking about additional SQL building facilities there.
Your work is certainly inspiring, and it’d be great to see if it can be integrated with mine (or if I can learn something from it).
Looking at predicates like table_def, my extension can provide this to Prolog functions on demand.
I’m glad you find pro2sql of interest. I had a quick look at the SWI-Prolog integration to Omnigress, but I couldn’t see examples of how it might work, so I’m not entirely sure where prolog fits into the picture. This is probably compounded by my unfamiliarity with Postgresql.
However, I’d be happy to answer questions about pro2sql if you want to take further steps to integrate it.