This project sets up a PostgreSQL database for a news website. The provided Python script project1.py uses the psycopg2 library to query the database and produce a report that answers the following questions:
- What are the most popular three articles of all time?
- "Candidate is jerk, alleges rival" -- 338647 views
- "Bears love berries, alleges bear" -- 253801 views
- "Bad things gone, say good people" -- 170098 views
- Who are the most popular article authors of all time?
- Ursula La Multa -- 507594 views
- Rudolf von Treppenwitz -- 423457 views
- Anonymous Contributor -- 170098 views
- Markoff Chaney -- 84557 views
- On which days did more than 1% of requests lead to errors?
- Jul 17,2016 -- 2.26% errors
- Python
- PostgreSQL
- psycopg2 library
- Please download news database: https://d17h27t6h515a5.cloudfront.net/topher/2016/August/57b5f748_newsdata/newsdata.zip
- Import news database: e.g. $ psql -d news -f newsdata.sql
- connect the news database with the command: psql news
- run the command first to create a view: create view log_view as select path,count(*) as num from log group by path having path!='/' order by num desc;
- disconnect the database, and run the command: $python project1.py