Using a connection service file
As the number of connection options grows, you may want to consider using a connection service file.
The connection service file allows you to give a single name to a set of connection parameters. This can be accessed centrally to avoid the need for individual users to know the host and port of the database, and it is more resistant to future change.
You can set up a system-wide file as well as individual per-user files. The default file paths for these files are /etc/pg_service.conf
and ~/.pg_service.conf
respectively.
A system-wide connection file controls service names for all users from a single place, while a per-user file applies only to that particular user. Keep in mind that the per-user file overrides the system-wide file – if a service is defined in both the files, then the definition in the per-user file will prevail.
How to do it…
First, create a file named pg_service.conf
with...