I am aiming to use R to connect to a database within PostgreSQL, for which I need to know the database host, port and user.
Do you know how I can find these details within PostgreSQL?
Thanks.
If you are using psql and already logged into the database, you can use the below command to display connection info
\conninfo
SELECT current_database() AS database, user AS user;
SHOW port;
If you are using psql(1), you can discover your hostname like this on linux and OSX, respectively:
\echo hostname
\echo scutil --get ComputerName