Skip to content

Commit 0293e52

Browse files
committed
update readme
1 parent 9439ecf commit 0293e52

File tree

1 file changed

+44
-33
lines changed

1 file changed

+44
-33
lines changed

README.md

Lines changed: 44 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,38 +13,34 @@ This is an application which uses Node.js to connect to IBM Db2 Warehouse on Clo
1313

1414
## Steps
1515

16-
1. [Clone the repo](#1-clone-the-repo)
17-
1. [Create IBM Db2 Warehouse on Cloud](#2-create-ibm-db2-warehouse-on-cloud)
18-
1. [Create schema and tables](#3-create-schema-and-tables)
19-
1. [Add Db2 credentials to .env file](#4-add-db2-credentials-to-env-file)
20-
1. [Run the application](#5-run-the-application)
16+
1. [Clone The Repo](#1-clone-the-repo)
17+
2. [Create IBM Db2 (Db2 Warehouse on Cloud or Db2 Docker Image)](#2-create-ibm-db2-(db2-warehouse-on-cloud-or-db2-docker-image))
18+
3. [Create Schema and Tables](#3-create-schema-and-tables)
19+
4. [Add Db2 Credentials to .env File](#4-add-db2-credentials-to-env-file)
20+
5. [Run The Application](#5-run-the-application)
2121

2222
### 1. Clone the repo
2323

2424
```bash
2525
git clone https://github.com/IBM/crud-using-nodejs-and-db2.git
2626
```
2727

28-
### 2a. Create IBM Db2 Warehouse on Cloud
28+
### 2. Create IBM Db2 (Db2 Warehouse on Cloud or Db2 Docker Image)
2929

30-
Create the Db2 Warehouse on Cloud service and make sure to note the credentials using the following link:
31-
32-
* [**IBM Db2 Warehouse on Cloud**](https://cloud.ibm.com/catalog/services/db2-warehouse)
30+
Once we have cloned our repository, the next thing we have to do is create our database that will hold our house sales data. There are two ways we can create our database. One way is creating IBM Db2 Warehouse on Cloud. This database will be hosted on the cloud. However, if you perfer to have your database on premise or locally, we can all use the Db2 Docker Image.
31+
32+
Choose which type of database you would like and follow the corresponding instructions:
3333

34-
### 2b. Create Schema and Tables for IBM Db2 Warehouse on Cloud
34+
1. Create IBM Db2 Warehouse on Cloud
35+
2. Create an IBM Db2 Docker Image (ON-Premise Database)
3536

36-
In the Db2 warehouse resource page, click on `Manage` and go to DB2 console by clicking the button `Open Console`. In the console do the following to load your data.
37+
#### 2a. Create IBM Db2 Warehouse on Cloud
3738

38-
* Click `Load` from the hamburger menu.
39-
* Click `Browse files` or you can drag files, select the [data/home-sales-training-data.csv](data/home-sales-training-data.csv) and click `Next`
40-
* Choose existing schema or create a new one named `DB2WML` by clicking `+ New Schema`
41-
* Create a new table named `HOME_SALES` by clicking `+ New Table` on the schema you created and click `Next`
42-
* Make sure the column names and data types displayed are correct, then click `Next`
43-
* Click `Begin Load` to load the data
39+
Create the Db2 Warehouse on Cloud service and make sure to note the credentials using the following link:
4440

45-
Once this is done it will create a table `HOME_SALES` under schema `DB2WML` which will be used by the Node.js application.
41+
* [**IBM Db2 Warehouse on Cloud**](https://cloud.ibm.com/catalog/services/db2-warehouse)
4642

47-
### 3a. Create an IBM Db2 ON-Premise Database
43+
#### 2b. Create an IBM Db2 ON-Premise Database
4844

4945
Instead of creating the Db2 Warehouse on Cloud service, we can also have our database instantiated locally by using the free IBM Db2 Docker Image.
5046

@@ -63,7 +59,7 @@ Steps to get your db2 running locally:
6359
```bash
6460
docker pull ibmcom/db2
6561

66-
docker run -itd --name mydb2 --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INST1_PASSWORD=hackathon -e DBNAME=testdb -v db2:/database ibmcom/db2
62+
docker run -itd --name mydb2 --privileged=true -p 50000:50000 -e LICENSE=accept -e DB2INST1_PASSWORD=hackathon -e DBNAME= homesalesdb -v db2:/database ibmcom/db2
6763

6864
docker exec -ti mydb2 bash -c "su - db2inst1"
6965
```
@@ -72,11 +68,35 @@ Once this is done, it will create a db2 docker container with the follow customi
7268

7369
* IP Address/Domain: `localhost`
7470
* Port: `50000`
75-
* Database name: `testdb`
71+
* Database name: `homesalesdb`
7672
* Username: `db2inst1`
7773
* Password: `hackathon`
7874

79-
### 3b. Create Schema and Tables for IBM Db2 Docker Image
75+
76+
### 3. Create Schema and Tables
77+
Now that we have created our databases, we need to import the data from the csv file into our database. We will be creating a schema called `DB2WML`. The two tables we will create are `HOME_SALES` and `HOME_ADDRESS`. `HOME_SALES` will store the data we retrieve from our csv file. `HOME_ADDRESS` is going to be the addresses associated with each home.
78+
79+
Depending on which type you have (Cloud or On-Premise), the steps will be a little different. Please follow the corresponding steps:
80+
81+
1. Create Schema and Tables for IBM Db2 Warehouse on Cloud
82+
2. Create Schema and Tables for IBM Db2 Docker Image
83+
84+
85+
#### 3a Create Schema and Tables for IBM Db2 Warehouse on Cloud
86+
87+
In the Db2 warehouse resource page, click on `Manage` and go to DB2 console by clicking the button `Open Console`. In the console do the following to load your data.
88+
89+
* Click `Load` from the hamburger menu.
90+
* Click `Browse files` or you can drag files, select the [data/home-sales-training-data.csv](data/home-sales-training-data.csv) and click `Next`
91+
* Choose existing schema or create a new one named `DB2WML` by clicking `+ New Schema`
92+
* Create a new table named `HOME_SALES` by clicking `+ New Table` on the schema you created and click `Next`
93+
* Make sure the column names and data types displayed are correct, then click `Next`
94+
* Click `Begin Load` to load the data
95+
96+
Once this is done it will create a table `HOME_SALES` under schema `DB2WML` which will be used by the Node.js application.
97+
98+
99+
#### 3b. Create Schema and Tables for IBM Db2 Docker Image
80100

81101
Exit out of the container shell by CONTROL-C. Load the sample data into the onprem Db2 database:
82102

@@ -93,10 +113,10 @@ docker exec -ti mydb2 bash -c "su - db2inst1"
93113
Steps To Create Schema and Tables:
94114

95115

96-
* Connect to the database `testdb` NOTE: This command may not work for sometime, since the container takes some time to create the database. If this command doesn work, please wait a couple minutes and then try again.
116+
* Connect to the database `homesalesdb` NOTE: This command may not work for sometime, since the container takes some time to create the database. If this command doesn work, please wait a couple minutes and then try again.
97117

98118
```bash
99-
db2 connect to testdb
119+
db2 connect to homesalesdb
100120
```
101121

102122
* Create Schema `DB2WML`
@@ -119,15 +139,6 @@ db2 'CREATE TABLE DB2WML.HOME_ADDRESS (ADDRESS1 VARCHAR(50), ADDRESS2 VARCHAR(50
119139
db2 'IMPORT FROM ../../../home-sales-training-data.csv OF DEL SKIPCOUNT 1 INSERT INTO DB2WML.HOME_SALES'
120140
```
121141

122-
123-
124-
125-
126-
127-
128-
129-
130-
131142
### 4. Add Db2 credentials to .env file
132143

133144
Copy the local `env.sample` file and rename it `.env`:

0 commit comments

Comments
 (0)