persistent-mysql-haskell-0.3.0.0: A pure haskell backend for the persistent library using MySQL database server.

Safe HaskellNone
LanguageHaskell98

Database.Persist.MySQL

Contents

Description

A MySQL backend for persistent.

Synopsis

Documentation

withMySQLPool Source #

Arguments

:: (MonadIO m, MonadLogger m, MonadBaseControl IO m, IsSqlBackend backend) 
=> MySQLConnectInfo

Connection information.

-> Int

Number of connections to be kept open in the pool.

-> (Pool backend -> m a)

Action to be executed that uses the connection pool.

-> m a 

Create a MySQL 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.

withMySQLConn Source #

Arguments

:: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) 
=> MySQLConnectInfo

Connection information.

-> (backend -> m a)

Action to be executed that uses the connection.

-> m a 

Same as withMySQLPool, but instead of opening a pool of connections, only one connection is opened.

createMySQLPool Source #

Arguments

:: (MonadBaseControl IO m, MonadIO m, MonadLogger m, IsSqlBackend backend) 
=> MySQLConnectInfo

Connection information.

-> Int

Number of connections to be kept open in the pool.

-> m (Pool backend) 

Create a MySQL connection pool. Note that it's your responsibility to properly close the connection pool when unneeded. Use withMySQLPool for automatic resource control.

mkMySQLConnectInfo Source #

Arguments

:: HostName

hostname

-> ByteString

username

-> ByteString

password

-> ByteString

database

-> MySQLConnectInfo 

Public constructor for MySQLConnectInfo.

setMySQLConnectInfoPort :: PortNumber -> MySQLConnectInfo -> MySQLConnectInfo Source #

Update port number for MySQLConnectInfo.

setMySQLConnectInfoCharset Source #

Arguments

:: Word8

Numeric ID of collation. See https://dev.mysql.com/doc/refman/5.7/en/show-collation.html.

-> MySQLConnectInfo

Reference connectInfo to perform update on

-> MySQLConnectInfo 

Update character set for MySQLConnectInfo.

mkMySQLConf Source #

Arguments

:: MySQLConnectInfo

The connection information.

-> Int

How many connections should be held on the connection pool.

-> MySQLConf 

Public constructor for MySQLConf.

mockMigration :: Migration -> IO () Source #

Mock a migration even when the database is not present. This function will mock the migration for a database even when the actual database isn't already present in the system.

TLS configuration

setMySQLConnectInfoTLS Source #

Arguments

:: ClientParams

ClientParams to establish a TLS connection with.

-> MySQLConnectInfo

Reference connectInfo to perform update on

-> MySQLConnectInfo 

Set TLS ClientParams for MySQLConnectInfo.

data TrustedCAStore :: * #

The whole point of TLS is that: a peer should have already trusted some certificates, which can be used for validating other peer's certificates. if the certificates sent by other side form a chain. and one of them is issued by one of TrustedCAStore, Then the peer will be trusted.

Constructors

SystemCAStore

provided by your operating system.

MozillaCAStore

provided by Mozilla.

CustomCAStore FilePath

provided by your self, the CA file can contain multiple certificates.

makeClientParams #

Arguments

:: TrustedCAStore

trusted certificates.

-> IO ClientParams 

make a simple tls ClientParams that will validate server and use tls connection without providing client's own certificate. suitable for connecting server which don't validate clients.

we defer setting of clientServerIdentification to connecting phase.

Note, tls's default validating method require server has v3 certificate. you can use openssl's V3 extension to issue such a certificate. or change ClientParams before connecting.

makeClientParams' #

Arguments

:: FilePath

public certificate (X.509 format).

-> [FilePath]

chain certificates (X.509 format). the root of your certificate chain should be already trusted by server, or tls will fail.

-> FilePath

private key associated.

-> TrustedCAStore

trusted certificates.

-> IO ClientParams 

make a simple tls ClientParams that will validate server and use tls connection while providing client's own certificate as well. suitable for connecting server which validate clients.

Also only accept v3 certificate.

Orphan instances