This project a part of Udacity Fullstack developer Nano Degree. This project is designed to provide a great SQL skills practice expereince by building a SQL reporting tool interacting with a database with over a million rows, both from the command line and from the code itself. Python programming language (python3) and postgresql are used for this particular project.
You must be familiar with the following before starting the project:
- Python
- PostgreSQL
- Vagagrant
- VirtualBox
- Install Python3
- Install and Configure Vagrant and VirtualBox
- Download or Clone the project from the github: https://github.com/udacity/fullstack-nanodegree-vm
- Download and install newsdata.sql in our vagrant directory
- Change the directory to vagrant
- Launch the virtual machine by following command $ vagrant up
- Log into vitural machine by this command $ vagrant ssh
- Change the directory to /vagrant
- run the following command to load the data in local database psql -d news -f newsdata.sql
- Use this command to see the database-> psql -d news
- Database contains 3 tables (authors, articles, and log) and to explore each one, use the following commands: \dt (note: that will display a list of tables that the database contains) \d table(note: replace table with actual table name)
- Use the below command to run the program python logs.py
A view, a virtual table based on the result-set of a postgre sql statement, is created for this project. Create the view as follows.
Create view popular_articles_view as select title, author, count(*) as views from articles join log on log.path=CONCAT('/article/',articles.slug) group by articles.author, articles.title order by views DESC;