Skip to content

PostgreSQL on IBM Cloud

We are using Postgresql as a data source to persist Product and Container information. The Produts table is used in the predictive model construction. So we need to provision a Postgresql service in IBM Cloud. Use the product documentation to provision your own service.

Here is a figure of the databases services in IBM Cloud as of December 2019.

Using the default configuration the service is created in a minutes. Once done, we need to define the service credentials for the host, user, password and the certificate to be used by client appliations.

Something like that:

" port=31384 
"PGPASSWORD": "2d1c526.....3"

From these informations we need to define the POSTGRES environment variables in the scripts/ file. (if not done before rename the scripts/ to scripts/


You also need to get the SSL certificate as a postgres.pem file, using the following ibmcloud CLI commands:

ibmcloud login
ibmcloud cdb deployment-cacert <database deployment name>

Then in set POSTGRES_SSL_PEM variable to the path where to find this file (export POSTGRES_SSL_PEM="./certs/postgres.pem").

Connect with psql

To validate the access, we use a public postgres docker image to run psql using the defined environment variables. We have a script to start it:

$ cd scripts
root@452074de376a:/# PGPASSWORD=$POSTGRES_PWD psql --host=$HOST --port=$PORT --username=$POSTGRES_USER --dbname=$POSTGRES_DB
ibmclouddb => 

List relations...

ibmclouddb => \d


You can use our tool to add some product definitions, for that see this note...