mysql function

Future<Database<Mysql>> mysql(
  1. MysqlOptions options, {
  2. void onQuery(
    1. QueryEvent
    )?,
  3. void onAcquire(
    1. AcquisitionEvent
    )?,
  4. void onDecode(
    1. DecodeEvent
    )?,
})

Connects to MySQL 8.4+ and returns a typed database owning that connection.

Completes after authentication, engine/version checks and session setup. MariaDB servers are rejected; use their separate entrypoint. TLS certificates are verified unless options explicitly selects another policy.

onQuery, onAcquire and onDecode observe runtime operations after opening; they do not include the initial connection handshake. Await Database.close when the application owner no longer needs the database. Opening a connection does not generate or apply a schema.

Implementation

Future<Database<Mysql>> mysql(
  MysqlOptions options, {
  void Function(QueryEvent)? onQuery,
  void Function(AcquisitionEvent)? onAcquire,
  void Function(DecodeEvent)? onDecode,
}) async => Database(
  await MysqlDriver.open(options),
  onQuery: onQuery,
  onAcquire: onAcquire,
  onDecode: onDecode,
);