MariaDB
@sqb/mariadb is the SQB adapter for MariaDB. It's built on top of
mariadb, the official
MariaDB Node.js connector.
Install
npm install @sqb/mariadb mariadb
@sqb/connect and @sqb/builder are peer dependencies pulled in transitively if you already
depend on them directly; otherwise install them alongside.
Registering the adapter
Importing @sqb/mariadb registers it as a side effect — there's nothing else to wire up:
import '@sqb/mariadb';
import { SqbClient } from '@sqb/connect';
const client = new SqbClient({
dialect: 'mariadb', // or driver: 'mariadb'
host: 'localhost',
database: 'mydb',
user: 'myuser',
password: 'mypassword',
});
Under the hood, @sqb/mariadb's entry point imports @sqb/mariadb-dialect (which teaches
@sqb/builder MariaDB's SQL syntax) and registers a MariadbAdapter instance with
AdapterRegistry. MariadbAdapter reports driver: 'mariadb' and dialect: 'mariadb'.
Configuration
host, port, user, password, and database from
ClientConfiguration map directly onto
the mariadb driver's own ConnectionConfig. Anything set in driverOptions is spread onto
that same options object first, so it can carry any option the driver supports that isn't
already covered by the standard fields:
new SqbClient({
dialect: 'mariadb',
host: 'localhost',
database: 'mydb',
driverOptions: {
charset: 'utf8mb4',
},
});
namedPlaceholders, decimalAsNumber, bigIntAsNumber, and insertIdAsNumber are always
forced to true by the adapter after driverOptions is applied (to keep numeric/id columns as
plain JS numbers, matching @sqb/mysql's behavior), so they can't be overridden through
driverOptions.
Feature notes
- Cursors: supported (
features.cursor: true), backed by the driver'squeryStream()— see Cursors & Streaming. - Schemas: not supported — MariaDB has no separate schema concept beyond the database itself.
RETURNING: MariaDB supportsINSERT ... RETURNINGandDELETE ... RETURNINGnatively, but has noUPDATE ... RETURNING. For updates, the dialect stripsRETURNINGand the adapter emulates it with a follow-upSELECTreusing the originalWHEREclause.
Migrator support
@sqb/migrator currently only implements its migration adapter for PostgreSQL — see
Running migrations. MariaDB migrations must be managed
outside @sqb/migrator today.
See also
- Choosing a Database Adapter
MariadbAdapterAPI reference- Creating a Client