CopyrightCopyright (C) 2017 Johannes Hartmann
LicenseMIT
MaintainerJohannes Hartmann <ec17512@qmul.ac.uk>
Stabilitystable
Portabilityportable
Safe HaskellNone

DataBaseModule

Description

This module handles all database related parts of the application.

Written by Johannes Hartmann

Synopsis

Documentation

dbConnect :: IO Connection Source #

Establishes the connection to the movie database

initialiseDB :: Connection -> IO () Source #

Given a connection to a database this function creates all the necessary tables if they don't already exist

clearDatabase :: Connection -> IO () Source #

drops all tables in the database

cleanupDatabase :: Connection -> String -> IO () Source #

removes all movies before a given date and deals with inconsistent states in the database after the deletion of a movie

disconnectDB :: Connection -> IO () Source #

Closes the database connection

insertMovieIntoDB :: Connection -> [Movie] -> IO () Source #

Inserts a given list of movies into the movies table

insertActorIntoDB :: Connection -> [Actor] -> IO () Source #

Inserts a given list of actors into the actors table and fills the plays relation table with all actor-movie connections

searchMoviesInDB :: Connection -> String -> IO (Maybe [Movie]) Source #

Looks up all movies a given actor plays in and returns a maybe list of movies. The Maybe will return Nothing if there is no movie for a given actor

getMoviesFromDatabase :: Connection -> IO [Movie] Source #

looks up all movies in the database and returns a list of all actors

getActorsFromDatabase :: Connection -> IO [Actor] Source #

looks up all actors in the database and returns a list of all actors

getDateOfLastMoveInDB :: Connection -> IO (Maybe String) Source #

returns the date of the newest movie in the Database