Skip to content
This project is a script that analyzes mock news data, including Articles, Authors, and Logs, in a PostgreSQL database
Python
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
log_results.txt
newsdata.py

README.md

Project: Logs Analysis

This project is a script that analyzes mock news data, including Articles, Authors, and Logs, in a PostgreSQL database.

Getting Started

Requirements

Installing

This project utilizes a virtual machine (VM) to run the SQL database server. To get setup:

  1. Download and install VirtualBox.

  2. Download and install Vagrant.

  3. Download the VM Configuration by using one of the following methods:

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.txt

The 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 log_results.txt file.

Database Views: No views were created for this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details.

You can’t perform that action at this time.