|
|
|
|
|
| Description |
| Module to connect to a PostgreSQL Database http://www.postgresql.org/
|
|
| Synopsis |
|
|
|
|
| Connection Creation |
|
| data DBService |
|
|
| createDBService |
| :: String | database server, either IP-address or servername | | -> String | name of the database to connect with | | -> String | commandline options to be sent to the server | | -> String | user name on server | | -> String | password of the user | | -> Maybe String | Just pathname specifies location of logfile,
Nothing selects default "/tmp/dbconnect.log" | | -> DBService | | | Create an open database handle |
|
|
| Data Manipulation |
|
| execute :: DBService -> QueryString -> IO Int |
| takes a data manipulating statement (insert or update),
sends it to the database and
returns the number of affected rows |
|
| Select Statements |
|
| selectReturnTuples :: DBService -> QueryString -> IO [[String]] |
| Executes a select query, returns the entire result |
|
| selectReturnRow :: DBService -> QueryString -> Int -> IO [String] |
| Executes a select query, returns the ith row |
|
| selectReturnList :: DBService -> QueryString -> IO [String] |
| Executes a select query, returns a list of the first elements of each tuple,
the same as
do {i <- selectReturnTuples query; return (map head i)} |
|
| selectReturnOne :: DBService -> QueryString -> IO String |
| Executes a select query, returns the first element of the
first row, or "" if the result is empty.
Useful if the query result is a single value |
|
| Exceptions |
|
| catchDB :: IO a -> (DBException -> IO a) -> IO a |
|
| data DBException |
| Specifies an Exception which may be thrown by createDBService or any of
the DBService functions. Use catchDB to catch this Exception in the main routine.
See also: DBConnectExample. | | Constructors | | DBError ErrorType String | Constructor taking the type of error and a string
with a more detailed description | | Exception | |
| | Instances | |
|
|
| data ErrorType |
| Specifies the type of an error, so you can do exception
handling depending on the type of exception | | Constructors | | ConnectionError | There's something wrong with the connection: usually the connection is broken | | ExecuteError | There's something wrong with the query: the execution returns
an error |
| | Instances | |
|
|
| Tools |
|
| setclause |
| :: String | columnname | | -> String | value | | -> String | | | Construct the string: "columname='value' " |
|
|
| setclausex |
| :: String | columnname | | -> String | value | | -> String | | | Construct the string: "columname='value'," |
|
|
| escapeQuery :: String -> String |
| Escaping a string. Useful to secure untrustworthy user input in forms |
|
| type QueryString = String |
|
| Produced by Haddock version 0.6 |