This is an informative tool from logs by sql database queries.
It Interacts with a live db from both command line and the python code.
PostgreSQL
inux-based virtual machine (VM) Vagrant
Reporting tool should answer the following questions:
What are the most popular three articles of all time?
Who are the most popular article authors of all time?
On which days did more than 1% of requests lead to errors?
This project makes use of Udacity's Linux-based virtual machine (VM) configuration which includes all of the necessary software to run the application.
VirtualBox is the software that actually runs the virtual machine.
You can download it from here
Vagrant is the software that configures the VM and lets you share files between host and the VM's filesystem.
You can downlaod it from here
you can use Github to fork and clone this repository.
Change your directory to this repository and do cd vagrant
From your terminal, inside the vagrant subdirectory, run the command vagrant up
This will cause Vagrant to download the Linux operating system and install it.
When vagrant up is finished running, you will get your shell prompt back.
At this point, you can run vagrant ssh to log in to your newly installed Linux VM!
Download the data here
Unzip this file after downloading it.
The file inside is called newsdata.sql
Put this file into the vagrant directory, which is shared with your virtual machine.
To load the data, cd into the vagrant directory and use the command psql -d news -f newsdata.sql
psql — the PostgreSQL command line program
-d news — connect to the database named news which has been set up for you
-f newsdata.sql — run the SQL statements in the file newsdata.sql
The required views are mentioned in create_views.sql
You need to just run this command psql -d news -f create_views.sql to create the views in database.
Once you have done all these steps, run this command python news.py to start the reporting tool. You will see the output in commandline
vagrant up ---> to start up the VM.
vagrant ssh ---> to log into the VM.
cd /vagrant ---> to change to your vagrant directory.
psql -d news -f newsdata.sql ---> to load the data and create the tables.
psql -d news -f create_views.sql ---> to create the views which can be reusable.
python news.py ---> to run the reporting tool.
pycodestyle news.py ---> to check for code standards and warnings
The code is error free and conforms to the PEP8 style recommendations.<br>
The code presents its output in clearly formatted plain text.