This program utilizes the postgreSQL database "news" from a news website to answer questions about that site's traffic. It will tell you the 3 most-visited articles, show how many views the site's authors have across all of their articles, and the days where more than 1% of requests led to errors.
The first thing to do is download answers.py and create-views.sql. Then, on a machine with PostgreSQL installed, you can create a database called "news" containing the following tables, and fill those tables with records:
CREATE TABLE articles (
author integer NOT NULL,
title text NOT NULL,
slug text NOT NULL,
lead text,
body text,
"time" timestamp with time zone DEFAULT now(),
id integer NOT NULL
);
CREATE TABLE authors (
name text NOT NULL,
bio text,
id integer NOT NULL
);
CREATE TABLE log (
path text,
ip inet,
method text,
status text,
"time" timestamp with time zone DEFAULT now(),
id integer NOT NULL
);
At that point, make sure answers.py and create-views.sql are in the same directory, and execute one of the following commands (depending on your python configuration):
python answers.py
or
python3 answers.py
- Make sure you have Python 3 installed
- Make sure you have PostgreSQL installed
- Make sure you have the psycopg2 library installed
pip3 psycopg2
- Bryan Williams - Initial work - willimsbw
- Udacity's team, who provided a pre-configured Vagrant VM and the database's content
See also the list of contributors who participated in this project.
- Thanks to Udacity for their nanodegree programs
- PurpleBooth, for providing this really great readme template