The project is for Udacity's full stack developer nano degree.
This project sets up a mock PostgreSQL database for a a fictional news website. The provided Python script uses psycopg2 library to query the database and produce a report that answers the following three questions:
- Find the most popular three articles of all time.
- Find the most popular article authors of all time.
- Find days where http requests has more than 1% error rate.
In addition to it, the provided Python script also leverages thread pool to run queries concurrently for the performance gain.
The project has already contained an output file named src/output.txt
which is the copy of
the query output. If you do not want to run the program to generate a new copy, you can directly check the file to see the output.
src
- contains all source code.src/db
- contains all db related operations.src/news.py
- contains the implementation of three queries.src/app.py
- entry point of the program.src/schema/create_views.sql
- includes views need to be created before runningapp.py
.
- Install latest version of Vagrant and VirtualBox if you do not have one.
- Unzip
schema/newsdata.sql.zip
into the same folder, you should getnewsdata.sql
as the output. - Optionally, you can overwrite
newsdata.sql
so the database will load your schema and data. - In the root directory, run
vagrant up
. - Run
vagrant ssh
to ssh into the VM. - In your VM, run
psql news -f /vagrant/schema/newsdata.sql
to load the data if are using your ownVagrantfile
. - In your VM, run
psql news -f /vagrant/schema/create_views.sql
to load the views if you are using your ownVagrantfile
. - In your VM, run
cd /vagrant/src
where you can find source code of the program. - Run
python3 app.py
to run the program. - you can then view the query output in
output.txt
located in thesrc
folder.