The project comprises a python script and a txt-file with a sample of its output that is normally written to a log-file. The python script comprises 3 psql-queries that in turn are making use of the views listed below and a function that sends the queries to the news database and writes the results to a log-file. The file normally expects a sql-database to be in the same folder. The queries are handed to the function log_search_results in form of a dictionary with task_1, task_2, task_3 as keys and the questions to be answered as well as the queries as values. The script is run like any regular python script in the shell: python3 project_1_submission.py
CREATE VIEW freq_dist_views AS SELECT count(PATH) AS num, PATH FROM log WHERE (PATH LIKE '_article%') AND (status = '200 OK') GROUP BY PATH;
CREATE VIEW authors_and_slugs AS SELECT articles.slug, authors.name FROM articles INNER JOIN authors ON articles.author = authors.id;
CREATE VIEW dates_and_status AS SELECT date(time) AS dates, status FROM log;