stakhanov-0.1.1.1: src/Database/PostgreSQL/Stakhanov/Connection.hs
{-# LANGUAGE CPP #-}
-- | This module is just here for a quick start with Stakhanov and Hasql, otherwise use the module [Hasql.Connection](https://hackage.haskell.org/package/hasql/docs/Hasql-Connection.html) and its subsequent modules to create full-blown Hasql connections.
module Database.PostgreSQL.Stakhanov.Connection where
import qualified Data.Text as T
import Hasql.Connection
import Hasql.Connection.Settings (connectionString)
import Hasql.Errors
#if MIN_VERSION_hasql(2,0,0)
import Pqi.Ffi
#endif
-- | Get a local PostgreSQL connection to a Docker container of PGMQ, with the default PostgreSQL connection string "__postgres:\/\/postgres:postgres@0.0.0.0:5432/postgres__".
acquireLocalPGConn :: IO (Either ConnectionError Connection)
#if MIN_VERSION_hasql(2,0,0)
acquireLocalPGConn = acquire adapter $ connectionString "postgres://postgres:postgres@0.0.0.0:5432/postgres"
#else
acquireLocalPGConn = acquire $ connectionString "postgres://postgres:postgres@0.0.0.0:5432/postgres"
#endif
-- | Get a PostgreSQL connection configured with the given PostgreSQL connection string.
acquirePGConn :: T.Text -> IO (Either ConnectionError Connection)
#if MIN_VERSION_hasql(2,0,0)
acquirePGConn t = acquire adapter $ connectionString t
#else
acquirePGConn t = acquire $ connectionString t
#endif