Safe Haskell | None |
---|
A front-end implementation for the PostgreSQL database protocol version 3.0 (implemented in PostgreSQL 7.4 and later).
- begin :: (MonadCatchIO m, MonadIO m) => Connection -> m ()
- rollback :: (MonadCatchIO m, MonadIO m) => Connection -> m ()
- commit :: (MonadCatchIO m, MonadIO m) => Connection -> m ()
- query :: MonadCatchIO m => Connection -> ByteString -> m ([Field], [[Maybe ByteString]])
- exec :: MonadCatchIO m => Connection -> ByteString -> m Integer
- escapeBS :: ByteString -> ByteString
- connect :: MonadIO m => ConnectInfo -> m Connection
- defaultConnectInfo :: ConnectInfo
- close :: MonadIO m => Connection -> m ()
- withDB :: (MonadCatchIO m, MonadIO m) => ConnectInfo -> (Connection -> m a) -> m a
- withTransaction :: (MonadCatchIO m, MonadIO m) => Connection -> m a -> m a
- newPool :: MonadIO m => ConnectInfo -> m Pool
- pconnect :: MonadIO m => Pool -> m Connection
- withPoolConnection :: (MonadCatchIO m, MonadIO m) => Pool -> (Connection -> m a) -> m ()
Documentation
begin :: (MonadCatchIO m, MonadIO m) => Connection -> m ()Source
Begin a transaction.
rollback :: (MonadCatchIO m, MonadIO m) => Connection -> m ()Source
Rollback a transaction.
commit :: (MonadCatchIO m, MonadIO m) => Connection -> m ()Source
Commit a transaction.
:: MonadCatchIO m | |
=> Connection | The connection. |
-> ByteString | The query. |
-> m ([Field], [[Maybe ByteString]]) |
Run a simple query on a connection.
exec :: MonadCatchIO m => Connection -> ByteString -> m IntegerSource
Exec a command.
escapeBS :: ByteString -> ByteStringSource
Escape a string for PostgreSQL.
:: MonadIO m | |
=> ConnectInfo | |
-> m Connection | The datase connection. |
Connect with the given username to the given database. Will throw an exception if it cannot connect.
defaultConnectInfo :: ConnectInfoSource
Default information for setting up a connection.
Defaults are as follows:
- Server on
localhost
- User
postgres
- No password
- Database
test
- Character set
utf8
Use as in the following example:
connect defaultConnectInfo { connectHost = "db.example.com" }
:: MonadIO m | |
=> Connection | The connection. |
-> m () |
Close a connection. Can safely be called any number of times.
withDB :: (MonadCatchIO m, MonadIO m) => ConnectInfo -> (Connection -> m a) -> m aSource
Run a an action with a connection and close the connection afterwards (protects against exceptions).
withTransaction :: (MonadCatchIO m, MonadIO m) => Connection -> m a -> m aSource
With a transaction, do some action (protects against exceptions).
pconnect :: MonadIO m => Pool -> m ConnectionSource
Connect using the connection pool.
:: (MonadCatchIO m, MonadIO m) | |
=> Pool | The connection pool. |
-> (Connection -> m a) | Use the connection. |
-> m () |
Use the connection pool.