Skip to content

A CLI application to fetch and view petroleum data.

Notifications You must be signed in to change notification settings

yuktibhatt/Petroleum-CLI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CLI App with Node JS

Node.js is an open-source, cross-platform, back-end JavaScript runtime environment that runs on the Chrome V8 engine and executes JavaScript code outside a web browser.

This CLI app helps us to fetch the petroleum data and view it according to the given questions.


Installation

Headover to the https://nodejs.org/ and download the latest version of the node. The current version will have all the latest feature but may not be stable. So, for most of the cases we download the LTS version.

So, go head and click the LTS version download link button and download it to your computer. Go through the installation process and the Node.js will be installed to your computer.

Now, we have installed the Node.js in our computer and how do we know actually that it is installed or not.

Open a terminal and type the following command to check the version installed.

$ node -v

Clone the repository

Clone the repository using your git bash or your terminal.

git clone https://[email protected]/yuktibhatt/yipl-intern-petroleum-report.git

Installing Node Modules

Install the node modules as given below:

npm install

Install sqlite database (For windows)

SQLite is an in-process library that implements a self-contained, serverless, zero-configuration, transactional SQL database engine. The code for SQLite is in the public domain and is thus free for use for any purpose, commercial or private. SQLite is the most widely deployed database in the world with more applications than we can count, including several high-profile projects.

  1. Go to SQLite download page, and download precompiled binaries from Windows section.
  2. Download sqlite-shell-win32-.zip and sqlite-dll-win32-.zip zipped files.
  3. Create a folder C:>sqlite and unzip above two zipped files in this folder, which will give you sqlite3.def, sqlite3.dll and sqlite3.exe files.
  4. Add C:>sqlite in your PATH environment variable and finally go to the command prompt and issue sqlite3 command, which should display the following result.
C:\>sqlite3
SQLite version 3.7.15.2 2013-01-09 11:53:05
Enter ".help" for instructions
Enter SQL statements terminated with a ";"
sqlite>

*For any other system other than windows visit the following link for installation: https://www.tutorialspoint.com/sqlite/sqlite_installation.htm


Run Migrations

After installation of database, run the following command to make migrations

npm run migrate

CLI Commands

  1. To Fetch data for Petroleum Products from the data.json file using an API call. API endpoint https://raw.githubusercontent.com/younginnovations/internship-challenges/master/programming/petroleum-report/data.json
node index.js fetch-oil-data
  1. To Store data in a file:
node index.js store-oil-data-in-file --filename data
  1. To store data in the database:
 node index.js store-oil-data --tablename reports
  1. To View all data:
     node index.js view-oil-data --tablename reports
  2. To view average sale of each product by country:
node index.js view-oil-data-avg --tablename reports
  1. To view year of minimum sale of each product:
node index.js view-oil-data-min --tablename reports

Example

  1. To fetch the year of minimum sale My Website

About

A CLI application to fetch and view petroleum data.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published