Database Configuration

Database configuration is done in the "insert_script.js" file in the database directory.

Directory

Directory to file from root directory:

database/insert_script.js

Database Initialisation

Database Initialisation is done in this directory. Database is injected from the config.js file into the insert_script.js file for the creation of new database and purging of existing databases.

//code snippets

if (err) throw err;
//1. drop database if exist - purge records
con.query(`DROP DATABASE IF EXISTS ${database.database}`, function (err, result) {
if (err) throw err;
});
//2. create database if not exist - init database
con.query(`CREATE DATABASE IF NOT EXISTS ${database.database}`, function (err, result) {
if (err) throw err;
});
//3. select database
con.query(`USE ${database.database}`, function (err, result) {
if (err) throw err;
});

Table Creation

Table creation is also done in this page. Here is the schema of the table listed below together with the javascript code executed to create the table.

SCHEMA to create the table

Javascript code for the creation of the script.

Insertion of Records

Insertion of records are from the "clothing_dataset.csv". headers will the key in the key-value pair of json to insert the records into the database. Filename is obtained from the config.js file and injected into the insert_script.js file for the insertion process.

For the purposes of this demo project, 500 records have been prepared.

Changing of Records

Records may be changed directly in the clothing_dataset.csv file. the Headers will represent the key in the key-value pair in json to be used to retrieve value to be inserted into the database.

clothing_dataset.csv file sample

Last updated

Was this helpful?