Skip to content

Commit

Permalink
Connect using Connection Service File
Browse files Browse the repository at this point in the history
For those who already have their Connection Service Files setup, it is
useful not to have
to specify the configuration file.
By connection using the service=<name> format we delegate all the
resolving of service file
locations to libpq.
  • Loading branch information
Feike Steenbergen authored and alexeyklyukin committed Jun 30, 2017
1 parent a500a37 commit 1a13e49
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.rst
Expand Up @@ -69,7 +69,7 @@ By default, pg_view tries to autodetect all PostgreSQL clusters running on the s
- checks all arguments, picking the first that allows it to establish a connection
- if pg_view can't get either the port/host or port/socket_directory pair, bail out

If the program can't detect your connection arguments using the algorithm above, you can specify those arguments manually using the configuration file supplied with the -c option. This file should consist of one or more sections, each containing a key = value pair.
If the program can't detect your connection arguments using the algorithm above, you can specify those arguments manually using the configuration file supplied with the -c option. This file should consist of one or more sections, each containing a key = value pair. You can also use your Connection Service File.

The title of each section represents a database cluster name (this name is for display purposes only). The dbname parameter is `postgres` by default, and specifies the actual name of the database to connect to. The key-value pairs should contain connection parameters.

Expand Down
3 changes: 3 additions & 0 deletions pg_view/__init__.py
Expand Up @@ -204,6 +204,9 @@ def main():
if not establish_user_defined_connection(instance, conn, clusters):
logger.error('failed to acquire details about ' +
'the database cluster {0}, the server will be skipped'.format(instance))
elif options.instance:
if not establish_user_defined_connection(options.instance, {'service': options.instance}, clusters):
logger.error("unable to continue with cluster {0}".format(options.instance))
elif options.host:
# try to connet to the database specified by command-line options
conn = build_connection(options.host, options.port, options.username, options.dbname)
Expand Down

0 comments on commit 1a13e49

Please sign in to comment.