This module defines basis data types and functions for accessing database systems using SQL. Currently, only SQLite3 is supported, but this is easy to extend. It also provides execution of SQL-Queries with types. Allowed datatypes for these queries are defined and the conversion to standard SQL-Queries is provided.
Author: Mike Tallarek, Michael Hanus
| fromSQLResult
                  ::  Either DBError a -> aGets the value of an SQLResult. | 
| printSQLResults
                  :: Show a => Either DBError [a] -> IO ()Print an SQLResult list, i.e., print either the DBError or the list of result elements. | 
| runDBAction
                  ::  DBAction a -> Connection -> IO (Either DBError a)Runs a DBActionon a connection. | 
| runInTransaction
                  ::  DBAction a -> DBAction aRun a DBActionas a transaction. | 
| (>+=)
                  ::  DBAction a -> (a -> DBAction b) -> DBAction bConnects two DBActions. | 
| (>+)
                  ::  DBAction a -> DBAction b -> DBAction bConnects two DBActions but ignore the result of the first. | 
| returnDB
                  ::  Either DBError a -> DBAction aReturns an SQLResult. | 
| failDB
                  ::  DBError -> DBAction aA failed DBActionwith a specific error. | 
| select
                  ::  String -> [SQLValue] -> [SQLType] -> DBAction [[SQLValue]]Execute a query where the result of the execution is returned. | 
| execute
                  ::  String -> [SQLValue] -> DBAction ()execute a query without a result | 
| executeMultipleTimes
                  ::  String -> [[SQLValue]] -> DBAction ()Executes a query multiple times with different SQLValues without a result | 
| connectSQLite
                  ::  String -> IO ConnectionConnect to a SQLite Database | 
| disconnect
                  ::  Connection -> IO ()Disconnect from a database. | 
| writeConnection
                  ::  String -> Connection -> IO ()Write a Stringto aConnection. | 
| begin
                  ::  DBAction ()Begin a transaction. | 
| commit
                  ::  DBAction ()Commit a transaction. | 
| rollback
                  ::  DBAction ()Rollback a transaction. | 
| setForeignKeyCheck
                  ::  Bool -> DBAction ()Turn on/off checking of foreign key constraints (SQLite3). | 
| runWithDB
                  ::  String -> DBAction a -> IO (Either DBError a)Executes an action dependent on a connection on a database by connecting to the datebase. | 
| executeRaw
                  ::  String -> [String] -> DBAction [[String]]Executes an SQL statement. | 
| getColumnNames
                  ::  String -> DBAction [String]Returns a list with the names of every column in a table The parameter is the name of the table. | 
| valueToString
                  ::  SQLValue -> String | 
              The result of SQL-related actions. It is either a DBError
              or some value.
            
              Type synonym: SQLResult a = Either DBError a
            
              DBErrors are composed of an DBErrorKind
              and a String
              describing the error more explicitly.
            
Constructors:
DBError
                    ::  DBErrorKind ->  String -> DBError
              The different kinds of errors.
Constructors:
TableDoesNotExist
                    :: DBErrorKind
              ParameterError
                    :: DBErrorKind
              ConstraintViolation
                    :: DBErrorKind
              SyntaxError
                    :: DBErrorKind
              NoLineError
                    :: DBErrorKind
              LockedDBError
                    :: DBErrorKind
              UnknownError
                    :: DBErrorKind
              Data type for SQL values, used during the communication with the database.
Constructors:
SQLString
                    ::  String -> SQLValue
              SQLInt
                    ::  Int -> SQLValue
              SQLFloat
                    ::  Float -> SQLValue
              SQLChar
                    ::  Char -> SQLValue
              SQLBool
                    ::  Bool -> SQLValue
              SQLDate
                    ::  ClockTime -> SQLValue
              SQLNull
                    :: SQLValue
              
              Type identifiers for SQLValues, necessary to determine the type
of the value a column should be converted to.
            
Constructors:
SQLTypeString
                    :: SQLType
              SQLTypeInt
                    :: SQLType
              SQLTypeFloat
                    :: SQLType
              SQLTypeChar
                    :: SQLType
              SQLTypeBool
                    :: SQLType
              SQLTypeDate
                    :: SQLType
              
              A DBAction
              takes a connection and performs an IO action that
returns a SQLResult a
              value.
            
Constructors:
Data type for database connections. Currently, only connections to a SQLite3 database are supported, but other types of connections could easily be added. The following functions might need to be re-implemented for other DBs: A function to connect to the database, disconnect, writeConnection readRawConnectionLine, parseLines, begin, commit, rollback, and getColumnNames
Constructors:
SQLiteConnection
                    ::  Handle -> Connection
              | 
                       Gets the value of an SQLResult. If there is no result value but a database error, the error is raised. | 
| 
                       Print an SQLResult list, i.e., print either the DBError or the list of result elements. | 
| 
                       
                      Runs a  | 
| 
                       
                      Run a  
 
 | 
| 
                       
                      Connects two  
 
 
 
 | 
| 
                       
                      Connects two  
 | 
| 
                       Execute a query where the result of the execution is returned. 
 
 
 | 
| 
                       execute a query without a result 
 
 
 | 
| 
                       Executes a query multiple times with different SQLValues without a result 
 
 
 | 
| 
                       Connect to a SQLite Database 
 
 
 | 
| 
                       Disconnect from a database. | 
| 
                       
                      Write a  | 
| Begin a transaction. Inside a transaction, foreign key constraints are checked. | 
| 
                       Turn on/off checking of foreign key constraints (SQLite3). | 
| 
                       Executes an action dependent on a connection on a database by connecting to the datebase. The connection will be kept open and re-used for the next action to this database. 
 
 
 | 
| 
                       Executes an SQL statement. The statement may contain ? placeholders and a list of parameters which should be inserted at the respective positions. The result is a list of list of strings where every single list represents a row of the result. | 
| 
                       Returns a list with the names of every column in a table The parameter is the name of the table. | 
| 
                       |