Logs Analysis project, part of the Udacity Full Stack Web Developer Nanodegree.
This project analyze the log data by querying SQL and outputs the data into a text file. This project runs directly from command line and does not take any input from the user.
PostgreSQL along with Psycopg 2 most popular PostgreSQL database adapter for the Python programming language.
- main.py - This file contain code for querying the database and processing it.
- out.txt - This file contains the output of main.py
- newsdata.zip - This contain the databse file that is used to import database.
- PostgreSQL - Download Here
- Python 3 - Download Here
- Psycopg 2 - install it using
pip install psycopg2
Download the project zip file to you computer and unzip the file. Or clone this repository to your desktop.
Navigate to the project directory.
Unzip newsdata.zip and run following code to import the newsdata.sql
psql -f newsdata.sql -U usernameAbove code will prompt for password enter the password
Now database 'news' has been created containg tables
- articles
- log
- authors
Run python program using command line or terminal
python main.pyA file named out.txt is created in the directory with output of the program in it.
- In main.py you must replace user and password with your own while connecting to the database.