All Projects → IBM → crud-using-nodejs-and-db2

IBM / crud-using-nodejs-and-db2

Licence: other
Create CRUD application using Node.js and IBM Db2 Database on Cloud

Programming Languages

HTML
75241 projects
typescript
32286 projects
javascript
184084 projects - #8 most used programming language
CSS
56736 projects

Projects that are alternatives of or similar to crud-using-nodejs-and-db2

global-citizen
WARNING: This repository is no longer maintained ⚠️ This repository, which contains assets to run a Hyperledger Composer application, is not being actively maintained due to a shift to focus on Hyperledger Fabric. This repository will not be updated. The repository will be kept available in read-only mode.
Stars: ✭ 54 (+260%)
Mutual labels:  ibmcode, ibmcloud
banking-digitalization-using-hybrid-cloud-with-mainframes
The following journey will introduce the available Banking APIs published on IBM Cloud with logical business programs running on the IBM Z Mainframe through a simulated retail bank called MPLbank.
Stars: ✭ 21 (+40%)
Mutual labels:  db2, ibmcode
db2-samples
Db2 application code, configuration samples, and other examples
Stars: ✭ 56 (+273.33%)
Mutual labels:  db2, db2warehouse
casc
CASC extractor for World of Warcraft data
Stars: ✭ 15 (+0%)
Mutual labels:  db2
DBFilesClient.NET
Deprecated: See DBClientFiles.NET
Stars: ✭ 14 (-6.67%)
Mutual labels:  db2
nodejs-postgresql-azure
Repositório responsável pela série de artigos sobre Node.js com PostgreSQL
Stars: ✭ 70 (+366.67%)
Mutual labels:  crud-application
gin-rest-api
Example golang using gin framework everything you need, i create this tutorial special for beginner.
Stars: ✭ 56 (+273.33%)
Mutual labels:  crud-application
watson-document-co-relation
Correlate text content across documents using Watson NLU, Python NLTK and Watson Studio.
Stars: ✭ 28 (+86.67%)
Mutual labels:  ibmcode
visualize-data-with-python
A Jupyter notebook using some standard techniques for data science and data engineering to analyze data for the 2017 flooding in Houston, TX.
Stars: ✭ 60 (+300%)
Mutual labels:  ibmcode
angularjs-php-mysql-crud
ANGULARJS PHP MySQL CRUD With Pagination
Stars: ✭ 14 (-6.67%)
Mutual labels:  crud-application
watson-stock-advisor
Create a web app for monitoring sentiment, price, and news for individual listed stocks, using IBM Watson Discovery and CloudantDB as well as Nodejs and Alpha Vantage.
Stars: ✭ 89 (+493.33%)
Mutual labels:  ibmcode
spring-boot-data-jpa-mysql
Spring Boot Rest CRUD API example - Spring Data JPA to interact with MySQL/PostgreSQL database.
Stars: ✭ 89 (+493.33%)
Mutual labels:  crud-application
gdpr-fingerprint-pii
Use Watson Natural Language Understanding and Watson Knowledge Studio to fingerprint personal data from unstructured documents
Stars: ✭ 49 (+226.67%)
Mutual labels:  ibmcode
sms-analysis-with-wks
Analyzing SMS offers for domain specific entities using Watson Knowledge Studio and Watson's Natural Language Understanding
Stars: ✭ 17 (+13.33%)
Mutual labels:  ibmcode
ncg-crud-ngx-md
Angular 4+ Material Design CRUD/Admin app by NinjaCodeGen http://DNAfor.NET
Stars: ✭ 36 (+140%)
Mutual labels:  crud-application
run-aspnetcore-basics retired
One Solution - One Project for web application development with Asp.Net Core & EF.Core. Only one web application project which used aspnetcore components; razor pages, middlewares, dependency injection, configuration, logging. To create websites with minimum implementation of asp.net core based on HTML5, CSS, and JavaScript. You can use this boi…
Stars: ✭ 15 (+0%)
Mutual labels:  crud-application
ar-resume-with-visual-recognition
An augmented reality based résumé with Face recognition. The iOS app recognizes the face and presents you with the AR view that contains 3D mock face and details of your resume.
Stars: ✭ 71 (+373.33%)
Mutual labels:  ibmcode
Leveraging-cache-and-MessagingQueue-to-scale-BlockchainNetwork
WARNING: This repository is no longer maintained ⚠️ This repository will not be updated. The repository will be kept available in read-only mode.
Stars: ✭ 28 (+86.67%)
Mutual labels:  ibmcode
alexa-skill-watson-assistant
Alexa Skill using IBM Watson Assistant and IBM Cloud Functions
Stars: ✭ 72 (+380%)
Mutual labels:  ibmcode
turi-create-movie-recommender
Creating a movie recommendation system for iOS with Turi Create
Stars: ✭ 25 (+66.67%)
Mutual labels:  ibmcode

Create a CRUD application using Node.js and IBM Db2 Warehouse on Cloud

This is an application which uses Node.js 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 Node.js and IBM Db2 Warehouse on Cloud.

Flow

Architecture Diagram

  1. Create schema and tables necessary for storing data in IBM Db2 Warehouse on Cloud.
  2. Node.js webapp that use node Db2 driver to connect to the database.
  3. Node.js app exposes API to interact with IBM Db2 Warehouse on Cloud.
  4. An Angular frontend application to collect home sales data and call API to store that data to IBM Db2 Warehouse on Cloud.

Video

CRUD application using Node.js and IBM Db2

Steps

  1. Clone The Repo
  2. Create an IBM Db2 Instance
  3. Create Schema and Tables
  4. Add Db2 Credentials to .env File
  5. Run The Application

1. Clone the repo

git clone https://github.com/IBM/crud-using-nodejs-and-db2.git

2. Create an IBM Db2 Instance

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 prefer to have your database on premise or locally, we can also use the Db2 Docker Image.

Choose which type of database you would like and follow the corresponding instructions:

  1. Create IBM Db2 Warehouse on Cloud
  2. Create IBM Db2 Database Locally Using Docker Image

2a. Create IBM Db2 Warehouse on Cloud

Create the Db2 Warehouse on Cloud service and make sure to note the credentials using the following link:

2b. Create an IBM Db2 On Premise Database

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.

Prerequisite:

  • A Docker account
  • Docker Desktop installed on your machine
  • Logging into your Docker account on Docker Desktop

Steps to get your db2 running locally:

  • Create a folder name db2
  • Open a terminal window and make sure your current directory is the same as where your db2 is located
  • Run the commands
docker pull ibmcom/db2

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

docker exec -ti mydb2 bash -c "su - db2inst1"

Once this is done, it will create a db2 docker container with the follow customizations:

  • IP Address/Domain: localhost
  • Port: 50000
  • Database name: homesalesdb
  • Username: db2inst1
  • Password: hackathon

3. Create Schema and Tables

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.

Depending on which type you have (Cloud or On-Premise), the steps will be a little different. Please follow the corresponding steps:

  1. Create Schema and Tables for IBM Db2 Warehouse on Cloud
  2. Create Schema and Tables for IBM Db2 Docker Image

3a. Create Schema and Tables for IBM Db2 Warehouse on Cloud

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 Load from the hamburger menu.
  • Click Browse files or you can drag files, select the data/home-sales-training-data.csv and click Next
  • Choose existing schema or create a new one named DB2WML by clicking + New Schema
  • Create a new table named HOME_SALES by clicking + New Table on the schema you created and click Next
  • Make sure the column names and data types displayed are correct, then click Next
  • Click Begin Load to load the data

We also need to create a table for HOME_ADDRESS, which will store the addresses of each house data. We won't be able to use the same instructions we used for HOME_SALES since we have no data to load.

  • Click Run SQL from the hamburger menu.
  • Click Blank, which will open a blank sql editor
  • Run the command
CREATE TABLE DB2WML.HOME_ADDRESS (ADDRESS1 VARCHAR(50), ADDRESS2 VARCHAR(50), CITY VARCHAR(50), STATE VARCHAR(5), ZIPCODE INTEGER, COUNTRY VARCHAR(50), HOME_ID INTEGER)

Once this is done it will create a table HOME_SALES and HOME_ADDRESS under schema DB2WML which will be used by the Node.js application.

3b. Create Schema and Tables for IBM Db2 Docker Image

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

docker cp data/home-sales-training-data.csv mydb2:home-sales-training-data.csv

Run the container and enter into the container shell:

docker exec -ti mydb2 bash -c "su - db2inst1"

Steps To Create Schema and Tables:

  • 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 of minutes and then try again.
db2 connect to homesalesdb
  • Create Schema DB2WML
db2 'CREATE SCHEMA DB2WML'
  • Create Table HOME_SALES and HOME_ADDRESS within Schema DB2WML
db2 'CREATE TABLE DB2WML.HOME_SALES (ID SMALLINT, LOTAREA INTEGER, BLDGTYPE VARCHAR(6),HOUSESTYLE VARCHAR(6), OVERALLCOND INTEGER, YEARBUILT INTEGER, ROOFSTYLE VARCHAR(7), EXTERCOND VARCHAR(2), FOUNDATION VARCHAR(6), BSMTCOND VARCHAR(2), HEATING VARCHAR(4), HEATINGQC VARCHAR(2),CENTRALAIR VARCHAR(1), ELECTRICAL VARCHAR(5), FULLBATH INTEGER, HALFBATH INTEGER, BEDROOMABVGR INTEGER, KITCHENABVGR VARCHAR(2), KITCHENQUAL VARCHAR(2), TOTRMSABVGRD INTEGER, FIREPLACES INTEGER, FIREPLACEQU VARCHAR(2), GARAGETYPE VARCHAR(7), GARAGEFINISH VARCHAR(3), GARAGECARS INTEGER, GARAGECOND VARCHAR(2), POOLAREA INTEGER, POOLQC VARCHAR(2), FENCE VARCHAR(6), MOSOLD INTEGER, YRSOLD INTEGER, SALEPRICE INTEGER )'

db2 'CREATE TABLE DB2WML.HOME_ADDRESS (ADDRESS1 VARCHAR(50), ADDRESS2 VARCHAR(50), CITY VARCHAR(50), STATE VARCHAR(5), ZIPCODE INTEGER, COUNTRY VARCHAR(50), HOME_ID INTEGER)'
  • Load data from CSV file to table HOME_SALES
db2 'IMPORT FROM ../../../home-sales-training-data.csv OF DEL SKIPCOUNT 1 INSERT INTO DB2WML.HOME_SALES'

4. Add Db2 credentials to .env file

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

    cp env.sample .env

Update 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>

5. Run the application

    npm install
    yarn install

In a two separate terminals run the following:

    ng serve --open

and

    node server.js

You can go to the UI by running the following URL in the browser: http://localhost:8888

Demo

demo

Learn more

  • Artificial Intelligence Code Patterns: Enjoyed this Code Pattern? Check out our other AI Code Patterns

License

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.

Apache License FAQ

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].