Skip to main content

MysqlAdapter

MysqlAdapter is the Adapter implementation shipped by @sqb/mysql, connecting to MySQL via mysql2. It self-registers with AdapterRegistry as a side effect of importing @sqb/mysql — see the MySQL adapter guide for setup and configuration.

import '@sqb/mysql';

Constructor

new MysqlAdapter()

Takes no arguments. You normally never construct this directly — importing @sqb/mysql registers a shared instance with AdapterRegistry for you.

Properties

PropertyTypeDescription
driver'mysql2'The driver name, matched against ClientConfiguration.driver.
dialect'mysql'The dialect name, matched against ClientConfiguration.dialect.
featuresAdapter.Features{ cursor: true, positionalParams: true }.

Methods

connect()

connect(config: ClientConfiguration): Promise<Adapter.Connection>

Opens one physical mysql2 connection. config.host, .port, .user, .password, and .database are mapped onto mysql2's ConnectionOptions; anything set in config.driverOptions is spread onto that same object first, before namedPlaceholders and decimalNumbers are forced to true. Returns a MysqlConnection wrapping the opened connection.

See also