How to connect to PostgreSQL database via SOCKS5 proxy in userspace networking mode

Hi! Is there any possibility to connect to a PostgreSQL database via the SOCKS5 proxy in userspace networking mode? As far as I was able to find out, libpg doesn’t seem to support specifying any kind of proxy.

The following thread touches upon using ncat, but doesn’t provide any examples: SOCKS proxy support struggles

The following answer makes me believe that this is maybe possible via socat? How do i use socat as a proxy server? - Server Fault

However, socat doesn’t support SOCKS5.

Any suggestions are appreciated!

Making very small progress. The following command allows me to reach an nginx server on another host but immediately closes upon request completion:

ncat -l localhost 8080 --sh-exec "ncat --proxy localhost:1055 --proxy-type socks5 8080"