Connection wrappers adapt a native driver to Inquire's Connection interface.
Each wrapper:
- exposes a dialect
- formats values for the native driver
- executes SQL
- manages transactions
- returns plain result arrays from
query()
All connection wrappers implement the same core shape.
| Property or method | Description |
|---|---|
dialect |
Active SQL dialect. |
lastId |
Last inserted id when the driver exposes one. |
before |
Hook that runs before the native query call. |
format(request) |
Adapts placeholders and values for the driver. |
query(request) |
Returns plain rows for application code. |
resource() |
Returns the native resource. |
transaction(callback) |
Runs work in a transaction. |
Some wrappers also expose a raw() method on the concrete class, but that method is not part of the shared Connection interface.
Package: @stackpress/inquire-mysql2
import mysql from 'mysql2/promise';
import connect from '@stackpress/inquire-mysql2';
const resource = await mysql.createConnection({
host: 'localhost',
user: 'root',
database: 'app'
});
const engine = connect(resource);Concrete class: Mysql2Connection
Notes:
- uses the
Mysqldialect - tracks
lastId - serializes dates, arrays, and objects in
format() - uses native
beginTransaction(),commit(), androllback()
Package: @stackpress/inquire-pg
import { Client } from 'pg';
import connect from '@stackpress/inquire-pg';
const client = new Client({
database: 'app',
user: 'postgres'
});
await client.connect();
const engine = connect(client);Concrete class: PGConnection
Notes:
- uses the
Pgsqldialect - rewrites
?placeholders to$1,$2, and so on - serializes dates, arrays, and objects in
format() - does not expose
lastId
Package: @stackpress/inquire-pglite
import { PGlite } from '@electric-sql/pglite';
import connect from '@stackpress/inquire-pglite';
const resource = new PGlite('./build/database');
const engine = connect(resource);Concrete class: PGLiteConnection
Notes:
- uses the
Pgsqldialect - shares the same placeholder conversion rules as PostgreSQL
- does not expose
lastId
Package: @stackpress/inquire-sqlite3
import sqlite from 'better-sqlite3';
import connect from '@stackpress/inquire-sqlite3';
const resource = sqlite(':memory:');
const engine = connect(resource);Concrete class: BetterSqlite3Connection
Notes:
- uses the
Sqlitedialect - converts booleans to
0or1 - tracks
lastIdthroughlastInsertRowid - treats
SELECTandINSERT ... RETURNINGas row-returning queries
Most application code should stay at the Engine level. Use the connection classes directly only when you need driver-specific behavior such as raw() access or direct access to the native resource().