Project: Logs Analysis
This project is a script that analyzes mock news data, including Articles, Authors, and Logs, in a PostgreSQL database.
This project utilizes a virtual machine (VM) to run the SQL database server. To get setup:
Download and install VirtualBox.
Download and install Vagrant.
Download the VM Configuration by using one of the following methods:
- Download and unzip the VM Configuration File to create a directory titled FSND-Virtual-Machine
- Use GitHub to fork and clone this repository https://github.com/udacity/fullstack-nanodegree-vm
To begin working with this project, fork and clone this repository in the vagrant subdirectory of the VM Configuration directory, and download the newsdata.sql file
In your terminal, change to the vagrant subdirectory
cd /FSND-Virtual-Machine/vagrant/ -- OR -- cd /fullstack-nanodegree-vm/vagrant/
While inside the vagrant subdirectory, run the command
vagrant up to initialize the virtual machine, and run the command
vagrant ssh to log in
Import the newsdata.sql data and schema to a database labeled news by running the command
psql -d news -f newsdata.sql
How to use?
The newsdata.py script provides a function
log_results() that writes the results of a SQL query to a .txt file labeled
log_results() function has two parameters:
query-- the SQL query to be executed
mode-- optional argument to specify the file mode (default "w+")
There are three SQL queries provided in the newsdata.py script:
pop_authors-- returns the top 3 most popular articles of all time (by page views)
pop_articles-- returns the most popular article authors of all time (by page views)
req_errors-- returns the day(s) on which more than 1% of requests led to errors
Running the newsdata.py script included in this repository will write the results of all three of the built-in SQL queries to the
Database Views: No views were created for this project.
This project is licensed under the MIT License - see the LICENSE.md file for details.