Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add driver for native Bun SQL and SQLite #58

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 43 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -26,7 +26,7 @@ sql:

## Supported engines and drivers

- PostgreSQL via [pg](https://www.npmjs.com/package/pg) or [postgres](https://www.npmjs.com/package/postgres).
- PostgreSQL via [pg](https://www.npmjs.com/package/pg), [postgres](https://www.npmjs.com/package/postgres) or [Bun SQL](https://bun.sh/docs/api/sql).
- MySQL via [mysql2](https://www.npmjs.com/package/mysql2).
- SQLite via [sqlite3](https://www.npmjs.com/package/better-sqlite3).

@@ -291,6 +291,26 @@ sql:
driver: postgres # npm package name
```

### PostgreSQL and Bun SQL

```yaml
version: '2'
plugins:
- name: ts
wasm:
url: https://downloads.sqlc.dev/plugin/sqlc-gen-typescript_0.1.4.wasm
sha256: 9b2f4eca095a3ba1f0f5e971e371ae52f991396efdb63728fc3e8df92c31ff5f
sql:
- schema: "schema.sql"
queries: "query.sql"
engine: postgresql
codegen:
- out: db
plugin: ts
options:
runtime: bun
driver: bun-sql # to use native SQL library of Bun 1.2
```

### MySQL and mysql2

@@ -334,6 +354,27 @@ sql:
driver: better-sqlite3 # npm package name
```

### SQLite and Bun SQLite

```yaml
version: '2'
plugins:
- name: ts
wasm:
url: https://downloads.sqlc.dev/plugin/sqlc-gen-typescript_0.1.4.wasm
sha256: 9b2f4eca095a3ba1f0f5e971e371ae52f991396efdb63728fc3e8df92c31ff5f
sql:
- schema: "schema.sql"
queries: "query.sql"
engine: sqlite
codegen:
- out: db
plugin: ts
options:
runtime: bun
driver: bun-sqlite # to use native SQLite library of Bun
```

## Development

If you want to build and test sqlc-gen-typescript locally, follow these steps:
@@ -390,4 +431,4 @@ Check the `Makefile` for details.
```

For more details on sqlc development, refer to the sqlc core development guide. This guide provides additional information on setting up and working with sqlc in general, which may be useful for contributors to this project.
https://docs.sqlc.dev/en/latest/guides/development.html
https://docs.sqlc.dev/en/latest/guides/development.html
176 changes: 176 additions & 0 deletions examples/bun-sql/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
\*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
\*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

\*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

\*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.cache
.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

.cache/

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp
.cache

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.\*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store

15 changes: 15 additions & 0 deletions examples/bun-sql/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# bun-postgres

To install dependencies:

```bash
bun install
```

To run:

```bash
bun run src/main.ts
```

This project was created using `bun init` in bun v1.0.11. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
25 changes: 25 additions & 0 deletions examples/bun-sql/bun.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"lockfileVersion": 1,
"workspaces": {
"": {
"name": "bun-postgres",
"devDependencies": {
"bun-types": "latest",
},
"peerDependencies": {
"typescript": "^5.0.0",
},
},
},
"packages": {
"@types/node": ["@types/node@22.13.4", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-ywP2X0DYtX3y08eFVx5fNIw7/uIv8hYUKgXoK8oayJlLnKcRfEYCxWMVE1XagUdVtCJlZT1AU4LXEABW+L1Peg=="],

"@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="],

"bun-types": ["bun-types@1.2.2", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-RCbMH5elr9gjgDGDhkTTugA21XtJAy/9jkKe/G3WR2q17VPGhcquf9Sir6uay9iW+7P/BV0CAHA1XlHXMAVKHg=="],

"typescript": ["typescript@5.7.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw=="],

"undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
}
}
11 changes: 11 additions & 0 deletions examples/bun-sql/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "bun-sql",
"module": "src/main.ts",
"type": "module",
"devDependencies": {
"bun-types": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
99 changes: 99 additions & 0 deletions examples/bun-sql/src/db/query_sql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Code generated by sqlc. DO NOT EDIT.

import { SQL } from "bun";

export const getAuthorQuery = `-- name: GetAuthor :one
SELECT id, name, bio FROM authors
WHERE id = $1 LIMIT 1`;

export interface GetAuthorArgs {
id: string;
}

export interface GetAuthorRow {
id: string;
name: string;
bio: string | null;
}

export async function getAuthor(sql: SQL, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
const rows = await sql.unsafe(getAuthorQuery, [args.id]).values();
if (rows.length !== 1) {
return null;
}
const row = rows[0];
if (!row) {
return null;
}
return {
id: row[0],
name: row[1],
bio: row[2]
};
}

export const listAuthorsQuery = `-- name: ListAuthors :many
SELECT id, name, bio FROM authors
ORDER BY name`;

export interface ListAuthorsRow {
id: string;
name: string;
bio: string | null;
}

export async function listAuthors(sql: SQL): Promise<ListAuthorsRow[]> {
return (await sql.unsafe(listAuthorsQuery, []).values()).map(row => ({
id: row[0],
name: row[1],
bio: row[2]
}));
}

export const createAuthorQuery = `-- name: CreateAuthor :one
INSERT INTO authors (
name, bio
) VALUES (
$1, $2
)
RETURNING id, name, bio`;

export interface CreateAuthorArgs {
name: string;
bio: string | null;
}

export interface CreateAuthorRow {
id: string;
name: string;
bio: string | null;
}

export async function createAuthor(sql: SQL, args: CreateAuthorArgs): Promise<CreateAuthorRow | null> {
const rows = await sql.unsafe(createAuthorQuery, [args.name, args.bio]).values();
if (rows.length !== 1) {
return null;
}
const row = rows[0];
if (!row) {
return null;
}
return {
id: row[0],
name: row[1],
bio: row[2]
};
}

export const deleteAuthorQuery = `-- name: DeleteAuthor :exec
DELETE FROM authors
WHERE id = $1`;

export interface DeleteAuthorArgs {
id: string;
}

export async function deleteAuthor(sql: SQL, args: DeleteAuthorArgs): Promise<void> {
await sql.unsafe(deleteAuthorQuery, [args.id]);
}

46 changes: 46 additions & 0 deletions examples/bun-sql/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { SQL } from "bun";

import {
createAuthor,
deleteAuthor,
getAuthor,
listAuthors,
} from "./db/query_sql";

async function main() {
const sql = new SQL(); // You can also specify connection options here

// Create an author
const author = await createAuthor(sql, {
name: "Seal",
bio: "Kissed from a rose",
});
if (author === null) {
throw new Error("author not created");
}
console.log(author);

// List the authors
const authors = await listAuthors(sql);
console.log(authors);

// Get that author
const seal = await getAuthor(sql, { id: author.id });
if (seal === null) {
throw new Error("seal not found");
}
console.log(seal);

// Delete the author
await deleteAuthor(sql, { id: seal.id });
}

(async () => {
try {
await main();
process.exit(0);
} catch (e) {
console.error(e);
process.exit(1);
}
})();
22 changes: 22 additions & 0 deletions examples/bun-sql/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
"moduleResolution": "bundler",
"moduleDetection": "force",
"allowImportingTsExtensions": true,
"noEmit": true,
"composite": true,
"strict": true,
"downlevelIteration": true,
"skipLibCheck": true,
"jsx": "react-jsx",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"types": [
"bun-types" // add Bun global
]
}
}
176 changes: 176 additions & 0 deletions examples/bun-sqlite/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,176 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore

# Logs

logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*

# Diagnostic reports (https://nodejs.org/api/report.html)

report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json

# Runtime data

pids
_.pid
_.seed
\*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover

lib-cov

# Coverage directory used by tools like istanbul

coverage
\*.lcov

# nyc test coverage

.nyc_output

# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)

.grunt

# Bower dependency directory (https://bower.io/)

bower_components

# node-waf configuration

.lock-wscript

# Compiled binary addons (https://nodejs.org/api/addons.html)

build/Release

# Dependency directories

node_modules/
jspm_packages/

# Snowpack dependency directory (https://snowpack.dev/)

web_modules/

# TypeScript cache

\*.tsbuildinfo

# Optional npm cache directory

.npm

# Optional eslint cache

.eslintcache

# Optional stylelint cache

.stylelintcache

# Microbundle cache

.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/

# Optional REPL history

.node_repl_history

# Output of 'npm pack'

\*.tgz

# Yarn Integrity file

.yarn-integrity

# dotenv environment variable files

.env
.env.development.local
.env.test.local
.env.production.local
.env.local

# parcel-bundler cache (https://parceljs.org/)

.cache
.parcel-cache

# Next.js build output

.next
out

# Nuxt.js build / generate output

.nuxt
dist

# Gatsby files

.cache/

# Comment in the public line in if your project uses Gatsby and not Next.js

# https://nextjs.org/blog/next-9-1#public-directory-support

# public

# vuepress build output

.vuepress/dist

# vuepress v2.x temp and cache directory

.temp
.cache

# Docusaurus cache and generated files

.docusaurus

# Serverless directories

.serverless/

# FuseBox cache

.fusebox/

# DynamoDB Local files

.dynamodb/

# TernJS port file

.tern-port

# Stores VSCode versions used for testing VSCode extensions

.vscode-test

# yarn v2

.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.\*

# IntelliJ based IDEs
.idea

# Finder (MacOS) folder config
.DS_Store

15 changes: 15 additions & 0 deletions examples/bun-sqlite/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
# bun-postgres

To install dependencies:

```bash
bun install
```

To run:

```bash
bun run src/main.ts
```

This project was created using `bun init` in bun v1.0.11. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime.
25 changes: 25 additions & 0 deletions examples/bun-sqlite/bun.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"lockfileVersion": 1,
"workspaces": {
"": {
"name": "bun-sqlite",
"devDependencies": {
"bun-types": "latest",
},
"peerDependencies": {
"typescript": "^5.0.0",
},
},
},
"packages": {
"@types/node": ["@types/node@22.13.5", "", { "dependencies": { "undici-types": "~6.20.0" } }, "sha512-+lTU0PxZXn0Dr1NBtC7Y8cR21AJr87dLLU953CWA6pMxxv/UDc7jYAY90upcrie1nRcD6XNG5HOYEDtgW5TxAg=="],

"@types/ws": ["@types/ws@8.5.14", "", { "dependencies": { "@types/node": "*" } }, "sha512-bd/YFLW+URhBzMXurx7lWByOu+xzU9+kb3RboOteXYDfW+tr+JZa99OyNmPINEGB/ahzKrEuc8rcv4gnpJmxTw=="],

"bun-types": ["bun-types@1.2.2", "", { "dependencies": { "@types/node": "*", "@types/ws": "~8.5.10" } }, "sha512-RCbMH5elr9gjgDGDhkTTugA21XtJAy/9jkKe/G3WR2q17VPGhcquf9Sir6uay9iW+7P/BV0CAHA1XlHXMAVKHg=="],

"typescript": ["typescript@5.7.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-84MVSjMEHP+FQRPy3pX9sTVV/INIex71s9TL2Gm5FG/WG1SqXeKyZ0k7/blY/4FdOzI12CBy1vGc4og/eus0fw=="],

"undici-types": ["undici-types@6.20.0", "", {}, "sha512-Ny6QZ2Nju20vw1SRHe3d9jVu6gJ+4e3+MMpqu7pqE5HT6WsTSlce++GQmK5UXS8mzV8DSYHrQH+Xrf2jVcuKNg=="],
}
}
11 changes: 11 additions & 0 deletions examples/bun-sqlite/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"name": "bun-sqlite",
"module": "src/main.ts",
"type": "module",
"devDependencies": {
"bun-types": "latest"
},
"peerDependencies": {
"typescript": "^5.0.0"
}
}
85 changes: 85 additions & 0 deletions examples/bun-sqlite/src/db/query_sql.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
// Code generated by sqlc. DO NOT EDIT.

import { Database } from "bun:sqlite";

export const getAuthorQuery = `-- name: GetAuthor :one
SELECT id, name, bio FROM authors
WHERE id = ? LIMIT 1`;

export interface GetAuthorArgs {
id: number;
}

export interface GetAuthorRow {
id: number;
name: string;
bio: string | null;
}

export async function getAuthor(database: Database, args: GetAuthorArgs): Promise<GetAuthorRow | null> {
const stmt = database.prepare(getAuthorQuery);
const rows = stmt.values(args.id);
if (rows.length !== 1) {
return null;
}
const row = rows[0];
if (!row) {
return null;
}
return {
id: row[0] as number,
name: row[1] as string,
bio: row[2] as string | null
};
}

export const listAuthorsQuery = `-- name: ListAuthors :many
SELECT id, name, bio FROM authors
ORDER BY name`;

export interface ListAuthorsRow {
id: number;
name: string;
bio: string | null;
}

export async function listAuthors(database: Database): Promise<ListAuthorsRow[]> {
const stmt = database.prepare(listAuthorsQuery);
const rows = stmt.values();
return rows.map(row => ({
id: row[0] as number,
name: row[1] as string,
bio: row[2] as string | null
}));
}

export const createAuthorQuery = `-- name: CreateAuthor :exec
INSERT INTO authors (
name, bio
) VALUES (
?, ?
)`;

export interface CreateAuthorArgs {
name: string;
bio: string | null;
}

export async function createAuthor(database: Database, args: CreateAuthorArgs): Promise<void> {
const stmt = database.prepare(createAuthorQuery);
stmt.run(args.name, args.bio);
}

export const deleteAuthorQuery = `-- name: DeleteAuthor :exec
DELETE FROM authors
WHERE id = ?`;

export interface DeleteAuthorArgs {
id: number;
}

export async function deleteAuthor(database: Database, args: DeleteAuthorArgs): Promise<void> {
const stmt = database.prepare(deleteAuthorQuery);
stmt.run(args.id);
}

46 changes: 46 additions & 0 deletions examples/bun-sqlite/src/main.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import { Database } from "bun:sqlite";

import {
createAuthor,
deleteAuthor,
getAuthor,
listAuthors,
} from "./db/query_sql";

async function main() {
const ddl = await Bun.file(`${import.meta.dir}/../../authors/sqlite/schema.sql`).text();
const database = new Database(":memory:");

// Create tables
database.exec(ddl);

// Create an author
await createAuthor(database, {
name: "Seal",
bio: "Kissed from a rose",
});

// List the authors
const authors = await listAuthors(database);
console.log(authors);

// Get that author
const seal = await getAuthor(database, { id: authors[0].id });
if (seal === null) {
throw new Error("seal not found");
}
console.log(seal);

// Delete the author
await deleteAuthor(database, { id: seal.id });
}

(async () => {
try {
await main();
process.exit(0);
} catch (e) {
console.error(e);
process.exit(1);
}
})();
22 changes: 22 additions & 0 deletions examples/bun-sqlite/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"compilerOptions": {
"lib": ["ESNext"],
"module": "esnext",
"target": "esnext",
"moduleResolution": "bundler",
"moduleDetection": "force",
"allowImportingTsExtensions": true,
"noEmit": true,
"composite": true,
"strict": true,
"downlevelIteration": true,
"skipLibCheck": true,
"jsx": "react-jsx",
"allowSyntheticDefaultImports": true,
"forceConsistentCasingInFileNames": true,
"allowJs": true,
"types": [
"bun-types" // add Bun global
]
}
}
6 changes: 0 additions & 6 deletions examples/node-better-sqlite3/src/main.ts
Original file line number Diff line number Diff line change
@@ -9,12 +9,6 @@ import {
listAuthors,
} from "./db/query_sql";

interface Author {
id: string;
name: string;
bio: string | null;
}

async function main() {
const ddl = await readFile(join(__dirname, "../../authors/sqlite/schema.sql"), { encoding: 'utf-8' });
const database = new Database(":memory:");
18 changes: 18 additions & 0 deletions examples/sqlc.dev.yaml
Original file line number Diff line number Diff line change
@@ -40,6 +40,15 @@ sql:
options:
runtime: bun
driver: postgres
- schema: "authors/postgresql/schema.sql"
queries: "authors/postgresql/query.sql"
engine: "postgresql"
codegen:
- plugin: ts
out: bun-sql/src/db
options:
runtime: bun
driver: bun-sql
- schema: "authors/mysql/schema.sql"
queries: "authors/mysql/query.sql"
engine: "mysql"
@@ -70,3 +79,12 @@ sql:
options:
runtime: node
driver: better-sqlite3
- schema: "authors/sqlite/schema.sql"
queries: "authors/sqlite/query.sql"
engine: "sqlite"
codegen:
- plugin: ts
out: bun-sqlite/src/db
options:
runtime: bun
driver: bun-sqlite
22 changes: 20 additions & 2 deletions examples/sqlc.yaml
Original file line number Diff line number Diff line change
@@ -3,7 +3,7 @@ plugins:
- name: ts
wasm:
url: https://downloads.sqlc.dev/plugin/sqlc-gen-typescript_0.1.3.wasm
sha256: 287df8f6cc06377d67ad5ba02c9e0f00c585509881434d15ea8bd9fc751a9368
sha256: fc0595e9eb137800bf863de769cd57abd8630ef5ef92f2c9d6faec271ca96d1e
sql:
- schema: "authors/postgresql/schema.sql"
queries: "authors/postgresql/query.sql"
@@ -41,6 +41,15 @@ sql:
options:
runtime: bun
driver: postgres
- schema: "authors/postgresql/schema.sql"
queries: "authors/postgresql/query.sql"
engine: "postgresql"
codegen:
- plugin: ts
out: bun-sql/src/db
options:
runtime: bun
driver: bun-sql
- schema: "authors/mysql/schema.sql"
queries: "authors/mysql/query.sql"
engine: "mysql"
@@ -58,4 +67,13 @@ sql:
out: bun-mysql2/src/db
options:
runtime: bun
driver: mysql2
driver: mysql2
- schema: "authors/sqlite/schema.sql"
queries: "authors/sqlite/query.sql"
engine: "sqlite"
codegen:
- plugin: ts
out: bun-sqlite/src/db
options:
runtime: bun
driver: bun-sqlite
9 changes: 8 additions & 1 deletion src/app.ts
Original file line number Diff line number Diff line change
@@ -5,7 +5,6 @@
import { readFileSync, writeFileSync, STDIO } from "javy/fs";
import {
EmitHint,
FunctionDeclaration,
NewLineKind,
TypeNode,
ScriptKind,
@@ -32,6 +31,8 @@ import { Driver as Sqlite3Driver } from "./drivers/better-sqlite3";
import { Driver as PgDriver } from "./drivers/pg";
import { Driver as PostgresDriver } from "./drivers/postgres";
import { Mysql2Options, Driver as MysqlDriver } from "./drivers/mysql2";
import { Driver as BunSqlDriver } from "./drivers/bun-sql";
import { Driver as BunSqliteDriver } from "./drivers/bun-sqlite";

// Read input from stdin
const input = readInput();
@@ -90,6 +91,12 @@ function createNodeGenerator(options: Options): Driver {
case "postgres": {
return new PostgresDriver();
}
case "bun-sql": {
return new BunSqlDriver();
}
case "bun-sqlite": {
return new BunSqliteDriver();
}
case "better-sqlite3": {
return new Sqlite3Driver();
}
622 changes: 622 additions & 0 deletions src/drivers/bun-sql.ts

Large diffs are not rendered by default.

475 changes: 475 additions & 0 deletions src/drivers/bun-sqlite.ts

Large diffs are not rendered by default.