This is an application which uses nodejs to connect to IBM Db2 Warehouse on cloud for CRUD(create, update, delete) operations. The application showcases how you can create a high performant CRUD application using nodejs and IBM Db2 Warehouse on cloud.
- Create schema and tables necessary for storing data in IBM DB2 Warehouse on cloud.
- Nodejs webapp that use node Db2 driver to connect to the database.
- Nodejs app exposes API to interact with IBM Db2 Warehouse on cloud.
- An Angular frontend application to collect home sales data and call API to store that data to IBM Db2 Warehouse on cloud.
- Clone the repo
- Create IBM Db2 Warehouse on Cloud
- Create schema and tables
- Add Db2 credentials to .env file
- Run the application
git clone https://github.com/IBM/crud-using-nodejs-and-db2.gitCreate the Db2 Warehouse on Cloud service and make sure to note the credentials using the following link:
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.
- Click
Loadfrom the hamburger menu. - Click
Browse filesor you can drag files, select the data/home-sales-training-data.csv and clickNext - Choose existing schema or create a new one named
DB2WMLby clicking+ New Schema - Create a new table named
HOME_SALESby clicking+ New Tableon the schema you created and clickNext - Make sure the column names and data types displayed are correct, then cick
Next - Click
Begin Loadto load the data
Once this is done it will create a table HOME_SALES under schema DB2WML which will be used by the nodejs application.
Copy the local env.sample file and rename it .env:
cp env.sample .envUpdate the .env file with the credentials from your Assistant service.
# Copy this file to .env and replace the credentials with # your own before starting the app. DB_DATABASE=<database name> DB_HOSTNAME=<hostname> DB_PORT=50000 DB_UID=<username> DB_PWD=<password> npm install yarn installIn a two separate terminals run the following:
ng serve --openand
node server.jsYou can go to the UI by running the following URL in the browser: http://localhost:8888
- Artificial Intelligence Code Patterns: Enjoyed this Code Pattern? Check out our other AI Code Patterns
This code pattern is licensed under the Apache License, Version 2. Separate third-party code objects invoked within this code pattern are licensed by their respective providers pursuant to their own separate licenses. Contributions are subject to the Developer Certificate of Origin, Version 1.1 and the Apache License, Version 2.
