# Database setup

Use the IBM Cloud console to launch the OpenShift web console

![web console](/files/-MHWIeLpIf5GhiclvCJc)

First create an 'Example Bank' namespace

![create project](/files/-MHWIeLqaQRezFn2xVAI)

From the navigation menu on the left select **Operators** --> **OperatorHub**

![operatorhub](/files/-MHWIeLrBaDamIwCwHCD)

Type 'Postgres' into the search bar, and select the **PostgreSQL Operator by Dev4Ddevs.com** tile.

![postgres operator](/files/-MHWIeLsZxP3CmG6auDx)

Click **Continue** to show the community operator and then **Install**

![install operator](/files/-MHWIeLtbvymfZ_1Vjxk)

Be sure you are installing the Operator in the `Example Bank` namespace, and click **Subscribe**

![subscribe](/files/-MHWIeLvs3FXj0xGJiza)

Status will show "Succeeded: Up to date" when complete

![succeeded](/files/-MHWIeLvs3FXj0xGJiza)

Use the very top drop down in the navigation menu on the left to switch to *Developer\** view

![developer view](/files/-MHWIgi1pkaPakGkc4LI)

Click **+Add** and select the Database tile

![add database](/files/-MHWIgi5_74BcwSATyk-)

Choose the **Database Database** tile and then **Create**

![database](/files/-MHWIgi6TlsUuGEyYmcx)

You can edit some of the specifics of the database here. For example, change the name to `creditdb` and click **Create**

![create database](/files/-MHWIgi7n7eWV2Ts9sgH)

Switch to the Topology tab, and watch your database creation complete!

![topology](/files/-MHWIgi8qlXmywyng2Yd) Use the very top drop down in the navigation menu on the left to switch to *Developer\** view

![developer view](/files/-MHWIgi1pkaPakGkc4LI)

Click **+Add** and select the Database tile

![add database](/files/-MHWIgi5_74BcwSATyk-)

Choose the **Database Database** tile and then **Create**

![database](/files/-MHWIgi6TlsUuGEyYmcx)

You can edit some of the specifics of the database here. For example, change the name to `creditdb` and click **Create**

![create database](/files/-MHWIgi7n7eWV2Ts9sgH)

Switch to the Topology tab, and watch your database creation complete!

![topology](/files/-MHWIgi8qlXmywyng2Yd)

Now we will need some CLI access. First, go to <https://labs.cognitiveclass.ai> and start a **Theia - Cloud IDE (With OpenShift)** session

![cognitiveclass](/files/-MHWIel18aFy0bnmJDw3)

back on your OpenShift web console, click you email address in the upper right corner and choose **Copy Login Command**

![copy login command](/files/-MJ7osSa1XHuwzr6HVyr)

From the resulting screen, grab your login credentials, and copy them into your ClognitiveClass terminal

![clusterlogin](/files/-MHWIel6qCBZXlB9EfhK)

switch to the example bank project:

```
oc project example-bank
```

Create a secret so the script that loads the schema can access the database

```
kubectl create secret generic bank-db-secret --from-literal=DB_SERVERNAME=creditdb --from-literal=DB_PORTNUMBER=5432 --from-literal=DB_DATABASENAME=example --from-literal=DB_USER=postgres --from-literal=DB_PASSWORD=postgres
```

Run the job to create the schema

```
oc apply -f data_model/job.yaml
```

![schema](https://raw.githubusercontent.com/IBM/example-bank/main/images/schema-1.png)

Verify that the schema load succeeded:

```
oc logs cc-schema-load-<pod>
```

Now that the database is ready, we can build and deploy the remaining microservices.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ibm-developer.gitbook.io/digital-developer-conference-hybrid-cloud/microservice-workshop-oss/oss/pg_full.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
