Copyright | 2016 Dylan Simon |
---|---|
Safe Haskell | None |
Language | Haskell98 |
Database.PostgreSQL.Typed.HDBC
Description
Use postgresql-typed as a backend for HDBC.
- data Connection
- connect :: PGDatabase -> IO Connection
- fromPGConnection :: PGConnection -> IO Connection
- withPGConnection :: Connection -> (PGConnection -> IO a) -> IO a
- reloadTypes :: Connection -> IO Connection
- connectionFetchSize :: Connection -> Word32
- setFetchSize :: Word32 -> Connection -> Connection
Documentation
data Connection Source #
A wrapped PGConnection
.
This differs from a bare PGConnection
in a few ways:
- It always has exactly one active transaction (with
pgBegin
) - It automatically disconnects on GC
- It provides a mutex around the underlying
PGConnection
for thread-safety
Instances
connect :: PGDatabase -> IO Connection Source #
fromPGConnection :: PGConnection -> IO Connection Source #
Convert an existing PGConnection
to an HDBC-compatible Connection
.
The caveats under connectionPG
apply if you plan to continue using the original PGConnection
.
withPGConnection :: Connection -> (PGConnection -> IO a) -> IO a Source #
Use the underlying PGConnection
directly. You must be careful to ensure that the first invariant is preserved: you should not call pgBegin
, pgCommit
, or pgRollback
on it. All other operations should be safe.
reloadTypes :: Connection -> IO Connection Source #
Reload the table of all types from the database. This may be needed if you make structural changes to the database.
setFetchSize :: Word32 -> Connection -> Connection Source #
Change the connectionFetchSize
for new Statement
s created with prepare
.
Ideally this could be set with each call to execute
and fetchRow
, but the HDBC interface provides no way to do this.