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.
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 using your git bash or your terminal.
git clone https://[email protected]/yuktibhatt/yipl-intern-petroleum-report.git
Install the node modules as given below:
npm install
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.
- Go to SQLite download page, and download precompiled binaries from Windows section.
- Download sqlite-shell-win32-.zip and sqlite-dll-win32-.zip zipped files.
- 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.
- 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
After installation of database, run the following command to make migrations
npm run migrate
- 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
- To Store data in a file:
node index.js store-oil-data-in-file --filename data
- To store data in the database:
node index.js store-oil-data --tablename reports
- To View all data:
node index.js view-oil-data --tablename reports
- To view average sale of each product by country:
node index.js view-oil-data-avg --tablename reports
- To view year of minimum sale of each product:
node index.js view-oil-data-min --tablename reports