hpqtypes-1.11.1.1: Haskell bindings to libpqtypes
Safe HaskellSafe-Inferred
LanguageHaskell2010

Database.PostgreSQL.PQTypes.Internal.Connection

Synopsis

Connection

newtype Connection Source #

Wrapper for hiding representation of a connection object.

Constructors

Connection 

data ConnectionData Source #

Representation of a connection object.

Note: PGconn is not managed with a ForeignPtr because finalizers are broken and at program exit might run even though another thread is inside the relevant withForeignPtr block, executing a safe FFI call (in this case executing an SQL query).

See https://gitlab.haskell.org/ghc/ghc/-/issues/10975 for more info.

Constructors

ConnectionData 

Fields

data ConnectionStats Source #

Simple connection statistics.

Constructors

ConnectionStats 

Fields

data ConnectionSettings Source #

Constructors

ConnectionSettings 

Fields

defaultConnectionSettings :: ConnectionSettings Source #

Default connection settings. Note that all strings sent to PostgreSQL by the library are encoded as UTF-8, so don't alter client encoding unless you know what you're doing.

newtype ConnectionSourceM m Source #

Database connection supplier.

Constructors

ConnectionSourceM 

Fields

newtype ConnectionSource (cs :: [(Type -> Type) -> Constraint]) Source #

Wrapper for a polymorphic connection source.

Constructors

ConnectionSource 

Fields

simpleSource :: ConnectionSettings -> ConnectionSource [MonadBase IO, MonadMask] Source #

Default connection supplier. It establishes new database connection each time withConnection is called.

poolSource Source #

Arguments

:: ConnectionSettings 
-> (IO Connection -> (Connection -> IO ()) -> PoolConfig Connection)

A function for creating the PoolConfig with desired parameters.

Note: supplied arguments are for creation and destruction of a database connection.

-> IO (ConnectionSource [MonadBase IO, MonadMask]) 

Pooled source. It uses striped pool from resource-pool package to cache established connections and reuse them.

connect :: ConnectionSettings -> IO Connection Source #

Low-level function for connecting to the database. Useful if one wants to implement custom connection source.

Warning: the Connection needs to be explicitly destroyed with disconnect, otherwise there will be a resource leak.

disconnect :: Connection -> IO () Source #

Low-level function for disconnecting from the database. Useful if one wants to implement custom connection source.

Running queries

runQueryIO :: IsSQL sql => Connection -> sql -> IO (Int, ForeignPtr PGresult) Source #

Low-level function for running an SQL query.

runPreparedQueryIO :: IsSQL sql => Connection -> QueryName -> sql -> IO (Int, ForeignPtr PGresult) Source #

Low-level function for running a prepared SQL query.