in reply to Connecting to a database in AWS using SSL
You can also connect by using a service connection file. Service names can be defined in either a per-user service file or a system-wide file. If the same service name exists in both the user and the system file, the user file takes precedence. By default, the per-user service file is named ~/.pg_service.conf. On Microsoft Windows, it is named %APPDATA% \postgresql\.pg_service.conf (where %APPDATA% refers to the Application Data subdirectory in the user's profile). A different file name can be specified by setting the environment variable PGSERVICEFILE. The system-wide file is named pg_service.conf. The location of this file can be controlled by setting the PGSYSCONFDIR environment variable. To use one of the named services within the file, set the name by using either the service parameter or the environment variable PGSERVICE. Note that when connecting this way, only the minimum parameters should be used. For example, to connect to a service named "zephyr", you could use:To isolate problems related to perl, you can use that same config file for standard pg commandline tools like 'psql'. If psql -d service=myservicename can connect, then perl should also.$dbh = DBI->connect("dbi:Pg:service=zephyr", '', '');You could also set $ENV{PGSERVICE} to "zephyr" and connect like this:
$dbh = DBI->connect("dbi:Pg:", '', '');
This also saves you from needing to alter the script when you deploy it in different environments. And with a single environment variable, you can override whether it's connecting to the production DB or your local copy for testing.
|
|---|