HaSSQL-1.0.0: Haskell Simple Structured Query Language

Safe HaskellSafe
LanguageHaskell2010

Database

Description

 
Synopsis

Documentation

sampleCommands :: IO Integer Source #

sampleCommands is for debugging purposes.

data Column Source #

Column stores a column in a table as a list of its values along with the datatype and name of column

Constructors

Column 
Instances
Eq Column Source # 
Instance details

Defined in Database

Methods

(==) :: Column -> Column -> Bool #

(/=) :: Column -> Column -> Bool #

Show Column Source # 
Instance details

Defined in Database

newColumn :: String -> Datatype -> [String] -> Maybe Column Source #

newColumn Returns new column (Maybe Column) First argument is name of column Second argument is datatype Third argument is list of values

data Table Source #

Table stores a map of columns (key is column Name) with table name and list of names of columns

Constructors

Table 
Instances
Eq Table Source # 
Instance details

Defined in Database

Methods

(==) :: Table -> Table -> Bool #

(/=) :: Table -> Table -> Bool #

Show Table Source # 
Instance details

Defined in Database

Methods

showsPrec :: Int -> Table -> ShowS #

show :: Table -> String #

showList :: [Table] -> ShowS #

newTable :: String -> ([String], Map String Column) -> [Int] -> Maybe Table Source #

newTable returns new table (Maybe Table) First argument is table name Second argument is (list of colNames, Map of those colnames -> Columns)

data Database Source #

Database stores a database with a name and map of tables indexed by their names

Constructors

Database 
Instances
Eq Database Source # 
Instance details

Defined in Database

Show Database Source # 
Instance details

Defined in Database

newDatabase :: String -> Map String Table -> Maybe Database Source #

newDatabase returns new database (Maybe Database) First argument is datbase name Second argument map of tables indexed by their names

data Datatype Source #

Datatype is for datatype in a column

Constructors

INT 
STRING 
BOOL 
Instances
Eq Datatype Source # 
Instance details

Defined in Database

Show Datatype Source # 
Instance details

Defined in Database

containsTable :: String -> Maybe Database -> Bool Source #

containsTable is True if database contains table, o/w False First argument is tableName Second argument is database object (Maybe database)

containsColumn :: String -> Maybe Database -> String -> Bool Source #

containsColumn returns True if table within database contains a column, o/w false First argument is column name Second argument is database (Maybe Database) Third argument is table name

getTable :: String -> Maybe Database -> Maybe Table Source #

getTable returns table from database (Maybe Table) First argument is table name Second argument is database (Maybe Database)

count :: Maybe Table -> Int Source #

count returns the number of entries in a table First argument is table (Maybe Table)

getColumn :: String -> Maybe Table -> Maybe Column Source #

getColumn returns column in specific table of a database (Maybe Column) First argument is name of column (String) Second argument is table (Maybe Table)

addNewTable :: String -> Maybe Database -> Maybe Database Source #

addNewTable adds an empty table to database and returns new database (Maybe Database) First argument is tableName (String) Second argument is database (Maybe Database)

addColumnToTable :: String -> Datatype -> Table -> Table Source #

addColumnToTable adds a column to a table and returns new table (Table) First argument is column name (String) Second argument is column datatype (Datatype) Third argumenr is old table (Table)

addColumn :: String -> Datatype -> Maybe Database -> String -> Maybe Database Source #

addColumn adds a column to specific table in database and returns new database (Maybe Database) First argument is column name (String) Second argumenr is column datatype (Datatype) Third argumenr is database (Maybe Database) Fourth argumenr is table name (String)

insertOne :: String -> Datatype -> Maybe Database -> String -> String -> Maybe Database Source #

insertOne inserts one entry in one column of one table in a database First argument is value (String) Second argument is it's datatype (Datatype) Third argument is old database (Maybe Database) Fourth argument is table name (String) Fifth argumenr is column name (String)

isValidDatatype :: Maybe Table -> [String] -> [Datatype] -> Bool Source #

isValidDatatype checks if datatypes corresponding to column names list are in sync with the table in database or not. Returns true if they both conform First argumenr is table (Maybe Table) Second argument is list of column names [String] Third argument is list of datatypes [Datatype]

addPrimaryKeyToTable :: Table -> Table Source #

addPrimaryKeyToTable adds one primary key to a table First argument is a table (Table)

addPrimaryKey :: Maybe Database -> String -> Maybe Database Source #

addPrimaryKey adds one primary key to table in database First argument is database (Maybe Database) Second argument is table name (String)

insert :: [String] -> [String] -> [Datatype] -> Maybe Database -> String -> Maybe Database Source #

insert inserts an entry (row) in database -> table and returns new database First argumenr is list of colNames [String] Second argument is corresponding list of values [String] Third argumenr is corresponding list of datatypes [Datatype] Fourth argument old database (Maybe Database) Fifth argument is table name (String)

insertDefault :: [String] -> Maybe Database -> String -> Maybe Database Source #

insertDefault inserts an entry in the default column order. This does not check for datatype as of now. First argument is list of values Second argument is old database Third argument is tableName

getColList :: String -> Maybe Database -> [Column] Source #

getColList is a Utility function for find*

findEntryAtIndex :: String -> Maybe Database -> Int -> [(Int, String, Datatype, String)] Source #

findEntryAtIndex finds entry at index in table and returns as [tuples] where tuple = (col name, col type, col value) First argument is tableName Second argument is database Third argument is index

litValue :: String -> Datatype -> ValueExpr Source #

litValue is a utility function to support evaluation of ValueExpr on columns (which are stored as String)

find :: Either ParseError ValueExpr -> Maybe Database -> String -> [[(Int, String, Datatype, String)]] Source #

find finds all entries in (db -> table) with value, datype and returns as [entries] where entry=[tuples] where tuple = (col name, col type, col value) First argument is value (Right) ValueExpr that evaluates to true or false Second argument is database (Maybe Database) Third argument is table name

deleteFromList :: Int -> [a] -> [a] Source #

deleteFromList is a utility function to delete an entry from a list

deleteEntryAtIndex :: Int -> Maybe Database -> String -> Maybe Database Source #

deleteEntryAtIndex deletes an entry from the table First argument is the index in table for the entry to be deleted Second argument is the database (Maybe Database) Third argument is table name

deleteEntryAtIndices :: [Int] -> Maybe Database -> String -> Maybe Database Source #

deleteEntryAtIndices is used to delete multiple entries from a specific table of a database First argument is list of indices [Int] Second argument is database (Maybe Database) Third argumenr is table name (String)

delete :: Either ParseError ValueExpr -> Maybe Database -> String -> Maybe Database Source #

delete deletes all entries that follow a specific condition from a table First argument is condition Second argument is Maybe Database Third argument is table name (String)

orderBy :: Either ParseError ValueExpr -> [[(Int, String, Datatype, String)]] -> [[(Int, String, Datatype, String)]] Source #

orderBy orders the entries given by find based on the value given by expression First argument is the expression that gives the deciding value Second argument is the entrylist returned by find / select

select :: [(String, String)] -> [[(Int, String, Datatype, String)]] -> [[(Int, String, Datatype, String)]] Source #

select selects specific columns from the output of find/orderBy and returns list of entries with those columns only First argument is column alias (if new name of the columns is needed, then this is used). If this is empty, all columns with default names are returned Second argument is output of find/orderBy