hasql-1.10.3: Fast PostgreSQL driver with a flexible mapping API
Safe HaskellNone
LanguageHaskell2010

Hasql.Connection.Settings

Synopsis

Settings

data Settings Source #

Connection settings.

This is a monoid, so you can combine multiple settings using mappend (<>). The rightmost setting takes precedence in case of conflicts.

With OverloadedStrings, you can declare settings using connection strings directly.

For example, using a key-value format:

>>> "host=localhost port=5432 user=myuser dbname=mydb" :: Settings
"postgresql://myuser@localhost:5432/mydb"

Or using a URI format:

>>> "postgresql://myuser@localhost:5432/mydb" :: Settings
"postgresql://myuser@localhost:5432/mydb"

You can achieve the same effect by constructing from a Text value:

>>> connectionString "host=localhost port=5432 user=myuser dbname=mydb"
"postgresql://myuser@localhost:5432/mydb"

Or use the provided constructors for better type safety and clarity:

>>> hostAndPort "localhost" 5432 <> user "myuser" <> dbname "mydb"
"postgresql://myuser@localhost:5432/mydb"

Instances

Instances details
Monoid Settings Source # 
Instance details

Defined in Hasql.Connection.Settings

Semigroup Settings Source # 
Instance details

Defined in Hasql.Connection.Settings

IsString Settings Source # 
Instance details

Defined in Hasql.Connection.Settings

Show Settings Source # 
Instance details

Defined in Hasql.Connection.Settings

Eq Settings Source # 
Instance details

Defined in Hasql.Connection.Settings

Constructors

host :: Text -> Settings Source #

Host domain name or IP-address.

To specify multiple alternate hosts, combine the produced settings via Monoid.

hostAndPort :: Text -> Word16 -> Settings Source #

Host domain name or IP-address and port.

Specifying a port without a host is not allowed due to how PostgreSQL handles connection strings.

This function creates a single host-port pair. To specify multiple alternate hosts, combine the results of multiple hostAndPort calls using the Monoid instance.

user :: Text -> Settings Source #

User name.

password :: Text -> Settings Source #

Password.

dbname :: Text -> Settings Source #

Database name.

applicationName :: Text -> Settings Source #

Application name.

other :: Text -> Text -> Settings Source #

Other param.

noPreparedStatements :: Bool -> Settings Source #

Whether prepared statements are disabled.

False by default.

When True, even the statements marked as preparable will be executed without preparation at the cost of reduced performance.

This is useful when dealing with proxying applications like pgbouncer, which may be incompatible with prepared statements. Consult their docs or just provide this setting to stay on the safe side. It should be noted that starting from version 1.21.0 pgbouncer now does provide support for prepared statements.

connectionString :: Text -> Settings Source #

Construct from a connection string in either URI or key-value format.

See the PostgreSQL documentation for details on the format.

If the connection string is invalid, it will be treated as empty.