Python
PostgreSQL
SQL Analytics
psycopg2
Python SQL Logs Analysis Reporting Tool
A Python reporting tool that connects to a PostgreSQL database containing web server logs and generates
structured analytical reports. Answers three key business questions: most-read articles, most popular
authors, and days with high error rates — all using pure SQL queries, no ORM.
- Pure SQL with
psycopg2 — no ORM abstraction, direct query control
- Identifies the top 3 most-read articles from the logs table
- Ranks authors by total combined article views across all their posts
- Flags any day where more than 1% of HTTP requests returned errors
- Output formatted as clean, readable plain-text reports
SELECT articles.title,
COUNT(log.path) AS views
FROM articles
JOIN log
ON log.path = CONCAT('/article/', articles.slug)
WHERE log.status = '200 OK'
GROUP BY articles.title
ORDER BY views DESC
LIMIT 3;