This project is for the log analysis of the news database.
The project uses two files and need python3 to run.
- loganalysis.py
- loganalysisdb.py
-
Make sure you have python3 installed on your machine.
-
Run below command to install psycopg2 module pip install psycopg2
-
Please download the vagrant/virtual machine from below url and follow the instructions to install.
-
Download the "news" data from below link. https://d17h27t6h515a5.cloudfront.net/topher/2016/August/57b5f748_newsdata/newsdata.zip
To load the data cd into vagrant folder and use below command to load data into 'news' in PSQL.
psql -d news -f newsdata.sql
-
Create below views in "news" database.
a. TopReads View CREATE VIEW TOPREADS AS SELECT articles.title, count(log.path) AS views FROM articles JOIN log ON log.path = ('/article/'::text || articles.slug) WHERE log.status = '200 OK'::text GROUP BY articles.title ORDER BY (count(log.path)) DESC;
b. Authart view CREATE VIEW AUTHART AS SELECT authors.name, articles.title FROM authors JOIN articles ON authors.id = articles.author;
-
Start vagrant machine and CD into the project folder. Run below command to execute the loganalysis file.
python3 loganalysis.py
#Vasudha Lalit
- Udacity
- http://pep8online.com