GitHub

API reference for config.

Settings of a MySQL client (Effect's @effect/sql-mysql2 MysqlClientConfig).

url (mysql://user:password@host:port/database) wins over every other connection field and over connect_options, as in Effect; it is checked when the config is made. Its query takes mysql2's ssl (an object such as ?ssl={"rejectUnauthorized":true}, values read as JSON) and connectTimeout (milliseconds); other options are refused. connect_options (Effect's poolConfig) are passed to asyncmy.connect as they are, for TLS (ssl), a unix_socket, init_command and the rest.

Values

AttributeTypeDescription
DEFAULT_MAX_CONNECTIONSLiteral[10] = 10

mysql2's connectionLimit.

DEFAULT_IDLE_TIMEOUTDuration

mysql2's idleTimeout.

Classes

Functions

parse_url

parse_url(url) -> UrlParts

The parts of a mysql:// URL; ValueError when it is not one.

ParameterTypeDescription
urlstr

Returns UrlParts

def parse_url(url: str) -> UrlParts:
    """The parts of a ``mysql://`` URL; ``ValueError`` when it is not
    one."""
    parts = urlsplit(url)
    if parts.scheme != "mysql":
        raise ValueError(f"expected a mysql:// URL, got scheme {parts.scheme!r}")
    if parts.fragment:
        raise ValueError("MySQL URLs take no fragment")
    if not parts.hostname:
        raise ValueError("the MySQL URL names no host")
    database = unquote(parts.path.removeprefix("/")) or None
    return UrlParts(
        host=parts.hostname,
        port=parts.port,
        database=database,
        username=None if parts.username is None else unquote(parts.username),
        password=None if parts.password is None else unquote(parts.password),
        options=parse_query(parts.query),
    )