Author: Lai Man Tang
Github: https://github.com/littlecloud1/news-logs-analysis
Date: 2018-8-16
This project aims to analysis the 'news' database and get the results of :
- the most popular three articles of all time
- the most popular article authors of all time
- the day that has more than 1% of requests lead to errors
To Run this program, you have to install following softwares:
- Python3
- PostgreSQL
- psycopg2
This project includes two codes file: news-report.py, newsdb.py and a output file: newsreport.txt
news-report.py: the main function to call the database and output the result into newsreort file.
newsdb.py: it connects to the 'news' database and get the result from the queries.
newsreport.txt: it is a example report that contains three analysis results
You need to download newsdata.sql and import it into database newsdata.sql
# Import Database:
psql -d news -f newsdata.sql
Before running this project you have to create a view inside the datebase:
CREATE VIEW articlesLog AS
SELECT au.name AS author,
a.title,
l.id AS logID,
l.status AS logStatus
FROM log AS l,
articles AS a,
authors AS au
WHERE l.path LIKE CONCAT('%/', a.slug)
AND au.id = a.author;
python news-report.py