Skip to content
Merged
Show file tree
Hide file tree
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
7 changes: 7 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,10 @@ PLANETSCALE_PASSWORD=password
# Cloudflare Hyperdrive
WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_POSTGRESQL=postgresql://test:test@localhost:5432/db0
WRANGLER_HYPERDRIVE_LOCAL_CONNECTION_STRING_MYSQL=mysql://test:test@localhost:3306/db0

# MSSQL
MSSQL_HOST=localhost
MSSQL_DB_NAME=TestDB
MSSQL_PORT=1433
MSSQL_USERNAME=sa
MSSQL_PASSWORD=MyStrong!Passw0rd
2 changes: 1 addition & 1 deletion .github/workflows/autofix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: npm i -g --force corepack && corepack enable
- run: npm i -fg corepack && corepack enable
- uses: actions/setup-node@v6
with: { node-version: lts/*, cache: pnpm }
- run: pnpm install
Expand Down
4 changes: 4 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,3 +15,7 @@ jobs:
- run: pnpm build
- run: pnpm test:types
- run: pnpm vitest
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
12 changes: 10 additions & 2 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,25 @@ services:
pg:
# https://hub.docker.com/_/postgres
image: postgres:alpine
network_mode: "host"
ports: ["5432:5432"]
environment:
POSTGRES_USER: test
POSTGRES_PASSWORD: test
POSTGRES_DB: db0
mysql:
# https://hub.docker.com/_/mysql
image: mysql
network_mode: "host"
ports: ["3306:3306"]
environment:
MYSQL_ROOT_PASSWORD: test
MYSQL_DATABASE: db0
MYSQL_USER: test
MYSQL_PASSWORD: test
mssql:
# https://hub.docker.com/_/microsoft-mssql-server
image: mcr.microsoft.com/mssql/server:2022-latest
ports: ["1433:1433"]
environment:
ACCEPT_EULA: "Y"
MSSQL_SA_PASSWORD: "MyStrong!Passw0rd"
MSSQL_PID: "Developer"
1 change: 1 addition & 0 deletions docs/2.connectors/1.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ Currently supported connectors:
- [PostgreSQL](/connectors/postgresql)
- [MySQL](/connectors/mysql)
- [SQLite](/connectors/sqlite)
- [MSSQL](/connectors/mssql)

::read-more{to="https://github.com/unjs/db0/issues/32"}
See [unjs/db0#32](https://github.com/unjs/db0/issues/32) for the list of upcoming connectors.
Expand Down
30 changes: 30 additions & 0 deletions docs/2.connectors/mssql.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
icon: devicon-plain:microsoftsqlserver
---

# MSSQL

> Connect DB0 to MSSQL Database using `tedious`

## Usage

For this connector, you need to install [`tedious`](https://www.npmjs.com/package/tedious) dependency:

:pm-install{name="tedious"}

Use `mssql` connector:

```js
import { createDatabase } from "db0";
import mssql from "db0/connectors/mssql";

const db = createDatabase(
mssql({
/* options */
}),
);
```

## Options

:read-more{to="https://tediousjs.github.io/tedious/api-connection.html#function_newConnection"}
46 changes: 26 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,46 @@
"release": "pnpm test && changelogen --release --push && pnpm publish",
"test": "pnpm lint && pnpm test:types && vitest run --coverage && pnpm test:bun",
"test:bun": "bun test ./test/connectors/bun-test.ts",
"test:types": "tsc --noEmit"
"test:types": "tsgo --noEmit"
},
"devDependencies": {
"@cloudflare/workers-types": "^4.20251120.0",
"@electric-sql/pglite": "^0.3.14",
"@libsql/client": "^0.15.15",
"@cloudflare/workers-types": "^4.20260122.0",
"@electric-sql/pglite": "^0.3.15",
"@libsql/client": "^0.17.0",
"@planetscale/database": "^1.19.0",
"@types/better-sqlite3": "^7.6.13",
"@types/bun": "^1.3.2",
"@types/pg": "^8.15.6",
"@vitest/coverage-v8": "^4.0.12",
"@types/bun": "^1.3.6",
"@types/pg": "^8.16.0",
"@typescript/native-preview": "7.0.0-dev.20260122.3",
"@vitest/coverage-v8": "^4.0.17",
"automd": "^0.4.2",
"better-sqlite3": "^12.4.1",
"better-sqlite3": "^12.6.2",
"changelogen": "^0.6.2",
"db0": "link:.",
"db0": "^0.3.4",
"dotenv": "^17.2.3",
"drizzle-orm": "^0.44.7",
"eslint": "^9.39.1",
"eslint-config-unjs": "^0.5.0",
"drizzle-orm": "^0.45.1",
"eslint": "^9.39.2",
"eslint-config-unjs": "^0.6.2",
"jiti": "^2.6.1",
"mlly": "^1.8.0",
"mysql2": "^3.15.3",
"obuild": "^0.4.2",
"pg": "^8.16.3",
"prettier": "^3.6.2",
"mysql2": "^3.16.1",
"obuild": "^0.4.19",
"pg": "^8.17.2",
"prettier": "^3.8.1",
"scule": "^1.3.0",
"tedious": "^19.1.3",
"typescript": "^5.9.3",
"vitest": "^4.0.12",
"wrangler": "^4.49.1"
"vitest": "^4.0.17",
"wrangler": "^4.60.0"
},
"peerDependencies": {
"@electric-sql/pglite": "*",
"@libsql/client": "*",
"better-sqlite3": "*",
"drizzle-orm": "*",
"mysql2": "*",
"sqlite3": "*"
"sqlite3": "*",
"tedious": "*"
},
"peerDependenciesMeta": {
"@libsql/client": {
Expand All @@ -90,14 +93,17 @@
"mysql2": {
"optional": true
},
"tedious": {
"optional": true
},
"@electric-sql/pglite": {
"optional": true
},
"sqlite3": {
"optional": true
}
},
"packageManager": "pnpm@10.23.0",
"packageManager": "pnpm@10.28.1",
"pnpm": {
"onlyBuiltDependencies": [
"better-sqlite3",
Expand Down
Loading
Loading