hsql-1.8.1: Simple library for database access from Haskell.



Basic type class & type definitions for DB interfacing.



data Connection Source

A Connection type represents a connection to a database, through which you can operate on the it. In order to create the connection you need to use the connect function from the module for your prefered backend.




connDisconnect :: IO ()

disconnect action

connExecute :: String -> IO ()

query execution action (without return value)

connQuery :: String -> IO Statement

query action with return value

connTables :: IO [String]

retrieval of the names of the tables in reach

connDescribe :: String -> IO [FieldDef]

retrieval of the field defs of a table

connBeginTransaction :: IO ()

begin of a transaction

connCommitTransaction :: IO ()

commit of a pending transaction

connRollbackTransaction :: IO ()

rollback of a pending transaction

connClosed :: MVar Bool

closing state of the connection

data Statement Source

The Statement type represents a result from the execution of given SQL query.




stmtConn :: Connection

field descriptors

stmtClose :: IO ()

closing action

stmtFetch :: IO Bool

incrementation of the row pointer and indication whether this is still in range of available rows

stmtGetCol :: forall a. Int -> FieldDef -> (FieldDef -> CString -> Int -> IO a) -> IO a

extraction of a field from the current result row, with

  • a column index
  • a column field definition
  • a generic field extraction function, specifiable by a field definition, a C string and its length
stmtFields :: [FieldDef]

field descriptors

stmtClosed :: MVar Bool

closing state of the statement

class SqlBind a whereSource


toSqlValue :: a -> StringSource

fromSqlValue :: SqlType -> String -> Maybe aSource

fromSqlCStringLen :: FieldDef -> CString -> Int -> IO aSource

This allows for faster conversion for eq. integral numeric types, etc. Default version uses fromSqlValue.