Skip to content

Type Method

mysql(hostname:port:username:password:database:tlsConfiguration:maxConnectionsPerEventLoop:connectionPoolTimeout:encoder:decoder:sqlLogLevel:)

Create a database configuration factory for connecting to a server with a hostname and optional port.
static func mysql(hostname: String, port: Int = 3306, username: String, password: String, database: String? = nil, tlsConfiguration: TLSConfiguration? = .makeClientConfiguration(), maxConnectionsPerEventLoop: Int = 1, connectionPoolTimeout: TimeAmount = .seconds(10), encoder: MySQLDataEncoder = .init(), decoder: MySQLDataDecoder = .init(), sqlLogLevel: Logger.Level? = .debug) -> DatabaseConfigurationFactory

Parameters

hostname

The hostname to connect to.

port

A TCP port number to connect on. Defaults to the IANA-assigned MySQL port number (3306).

username

The username to use for the connection.

password

The password (empty string for none) to use for the connection.

database

The default database for the connection, if any.

tlsConfiguration

An optional TLSConfiguration specifying encryption for the connection.

maxConnectionsPerEventLoop

The maximum number of database connections to add to each event loop’s pool.

connectionPoolTimeout

The timeout for queries on the connection pool’s wait list.

encoder

A MySQLDataEncoder used to translate bound query parameters into MySQLData values.

decoder

A MySQLDataDecoder used to translate MySQLData values into output values in SQLRows.

sqlLogLevel

The log level to use for logging serialized queries issued to databases using this configuration.

Return Value

An appropriate configuration factory.