Bun Sqlite¶
This runner provides integration with the Bun Sqlite driver, allowing ts-sql-query to execute queries on SQLite databases.
Supported databases
Tip
bun:sqlite supports synchronous query execution. See the Synchronous query runners for more information.
Do not share connections between requests
A ts-sql-query connection object — along with the query runner instances passed to its constructor — represents a dedicated connection to the database.
Therefore, you must not share the same connection object between concurrent HTTP requests. Instead, create a new connection object for each request, along with its own query runners.
Even if the query runner internally uses a connection pool, the ts-sql-query connection still represents a single active connection, acquired from the pool. It must be treated as such and never reused across requests.
Using a single connection¶
Enables executing queries through a dedicated Bun Sqlite connection.
import { BunSqliteQueryRunner } from "ts-sql-query/queryRunners/BunSqliteQueryRunner";
import { Database } from "bun:sqlite";
const db = new Database('foobar.db', options);
async function main() {
const connection = new DBConnection(new BunSqliteQueryRunner(db));
// Do your queries here
connection // ...
}
Safe Integers
If your queries may return integers larger than JavaScript's safe integer range, consider enabling safeIntegers in the database configuration.