Discovering connection strings
==============================

You can install PGD CLI on any system that can connect to the PGD
cluster. To use PGD CLI, you need a user with PGD superuser privileges
or equivalent. The PGD user with superuser privileges is the
:ref:`bdr_superuser role and replication <bdr_superuser role and replication>`  . An example of an equivalent user is edb_admin on an EDB
Cloud Service distributed high-availability cluster.

PGD CLI and database connection strings
---------------------------------------

You might not need a database connection string. For example, when
Trusted Postgres Architect installs the PGD CLI on a system, it also
configures the connection to the PGD cluster. This means that PGD CLI
can connect to the cluster when run.

Getting your database connection string
---------------------------------------

Because of the range of different configurations that PGD supports,
every deployment method has a different way of deriving a connection
string for it. Generally, you can obtain the required information from
the configuration of your deployment. You can then assemble that
information into connection strings.

For a cluster deployed with EDB CloudNative Postgres Global Cluster
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

If you are using EDB CloudNative Postgres Global Cluster (CNPG-GC), the
connection string is derived from the configuration of the deployment.
It is very flexible so there are multiple ways to obtain a connection
string. It depends, in large part, on the configuration of the
deployment’s `services <https://www.enterprisedb.com/docs/postgres_distributed_for_kubernetes/latest/connectivity/#services>`_  :

- If you use the Node Service Template, direct connectivity to each node
  and proxy service is available.

- If you use the Group Service Template, there’s a gateway service to
  each group.

- If you use the Proxy Service Template, a single proxy provides an
  entry point to the cluster for all applications.

\*\* TODO [DOCS-1499] : remove proxy references when CNPG-GC is updated
to use PGD6 CM \*\*

Consult your configuration file to determine this information.

Establish a host name or IP address, port, database name, and username.
The default database name is ``pgddb`` . The default username is
enterprisedb for EDB Postgres Advanced Server and postgres for
PostgreSQL and EDB Postgres Extended Server.

You can then assemble a connection string based on that information:

::

   "host=<hostnameOrIPAddress> port=<portnumber> dbname=<databasename> user=<username>"

If the deployment’s configuration requires it, add ``sslmode=<sslmode>``
.
