Safe Haskell | None |
---|---|
Language | Haskell98 |
Database.Persist.Postgresql
Description
A postgresql backend for persistent.
- withPostgresqlPool :: (MonadBaseControl IO m, MonadLogger m, MonadIO m) => ConnectionString -> Int -> (ConnectionPool -> m a) -> m a
- withPostgresqlConn :: (MonadIO m, MonadBaseControl IO m, MonadLogger m) => ConnectionString -> (SqlBackend -> m a) -> m a
- createPostgresqlPool :: (MonadIO m, MonadBaseControl IO m, MonadLogger m) => ConnectionString -> Int -> m ConnectionPool
- createPostgresqlPoolModified :: (MonadIO m, MonadBaseControl IO m, MonadLogger m) => (Connection -> IO ()) -> ConnectionString -> Int -> m ConnectionPool
- module Database.Persist.Sql
- type ConnectionString = ByteString
- data PostgresConf = PostgresConf {}
- openSimpleConn :: LogFunc -> Connection -> IO SqlBackend
- tableName :: forall record. (PersistEntity record, PersistEntityBackend record ~ SqlBackend) => record -> Text
- fieldName :: forall record typ. (PersistEntity record, PersistEntityBackend record ~ SqlBackend) => EntityField record typ -> Text
- mockMigration :: Migration -> IO ()
Documentation
Arguments
:: (MonadBaseControl IO m, MonadLogger m, MonadIO m) | |
=> ConnectionString | Connection string to the database. |
-> Int | Number of connections to be kept open in the pool. |
-> (ConnectionPool -> m a) | Action to be executed that uses the connection pool. |
-> m a |
Create a PostgreSQL connection pool and run the given
action. The pool is properly released after the action
finishes using it. Note that you should not use the given
ConnectionPool
outside the action since it may be already
been released.
withPostgresqlConn :: (MonadIO m, MonadBaseControl IO m, MonadLogger m) => ConnectionString -> (SqlBackend -> m a) -> m a Source
Same as withPostgresqlPool
, but instead of opening a pool
of connections, only one connection is opened.
Arguments
:: (MonadIO m, MonadBaseControl IO m, MonadLogger m) | |
=> ConnectionString | Connection string to the database. |
-> Int | Number of connections to be kept open in the pool. |
-> m ConnectionPool |
Create a PostgreSQL connection pool. Note that it's your
responsibility to properly close the connection pool when
unneeded. Use withPostgresqlPool
for an automatic resource
control.
createPostgresqlPoolModified Source
Arguments
:: (MonadIO m, MonadBaseControl IO m, MonadLogger m) | |
=> (Connection -> IO ()) | action to perform after connection is created |
-> ConnectionString | Connection string to the database. |
-> Int | Number of connections to be kept open in the pool. |
-> m ConnectionPool |
Same as createPostgresqlPool
, but additionally takes a callback function
for some connection-specific tweaking to be performed after connection
creation. This could be used, for example, to change the schema. For more
information, see:
https://groups.google.com/d/msg/yesodweb/qUXrEN_swEo/O0pFwqwQIdcJ
Since 2.1.3
module Database.Persist.Sql
type ConnectionString = ByteString Source
A libpq
connection string. A simple example of connection
string would be "host=localhost port=5432 user=test
dbname=test password=test"
. Please read libpq's
documentation at
http://www.postgresql.org/docs/9.1/static/libpq-connect.html
for more details on how to create such strings.
data PostgresConf Source
Information required to connect to a PostgreSQL database
using persistent
's generic facilities. These values are the
same that are given to withPostgresqlPool
.
Constructors
PostgresConf | |
Fields
|
openSimpleConn :: LogFunc -> Connection -> IO SqlBackend Source
Generate a Connection
from a Connection
tableName :: forall record. (PersistEntity record, PersistEntityBackend record ~ SqlBackend) => record -> Text Source
get the SQL string for the table that a PeristEntity represents Useful for raw SQL queries
fieldName :: forall record typ. (PersistEntity record, PersistEntityBackend record ~ SqlBackend) => EntityField record typ -> Text Source
get the SQL string for the field that an EntityField represents Useful for raw SQL queries
mockMigration :: Migration -> IO () Source
Mock a migration even when the database is not present.
This function performs the same functionality of printMigration
with the difference that an actualy database isn't needed for it.