SQLines Data - Configure and Troubleshoot Connection to PostgreSQL

If you are going to connect to a localhost PostgreSQL database you do not need to setup any additional libraries to use SQLines Data tool as they are already supplied with PostgreSQL server.

If you need to connect to a remote PostgreSQL database, you need to have PostgreSQL C API libpq (PostgreSQL native client software) installed in your system.

First check if you already have PostgreSQL libpq.so.5 library, for example:

  • Linux:
    • /usr/lib/libpq.so.5
    • /usr/lib64/libpq.so.5
    • /usr/pgsql-9.4/lib/libpq.so.5
    • /opt/postgres/9.0.4/server/lib/libpq.so.5

Note that many Linux distributions are supplied with PostgreSQL library by default. Try to find its location by running:

find / -name "libpq.so.5"

  • Windows: (Drive letter and version number can be different)
    • C:\Program Files\PostgreSQL\10\bin\libpq.dll

If you do not have PostgreSQL libraries installed, go to https://www.postgresql.org/download and install appropriate version.

SSL Connection to PostgreSQL

To enable SSL connection to PostgreSQL database server (i.e. Google Cloud SQL for PostgreSQL), set the following environment variables before running ./sqldata:

  export PGSSLMODE=require
  export PGSSLROOTCERT=server-ca.pem
  export PGSSLCERT=client-cert.pem
  export PGSSLKEY=client-key.pem