Skip to content
Open
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
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 }}
8 changes: 8 additions & 0 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,11 @@ services:
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
network_mode: "host"
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"}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@
"pg": "^8.17.2",
"prettier": "^3.8.1",
"scule": "^1.3.0",
"tedious": "^19.1.3",
"typescript": "^5.9.3",
"vitest": "^4.0.17",
"wrangler": "^4.60.0"
Expand All @@ -76,7 +77,8 @@
"better-sqlite3": "*",
"drizzle-orm": "*",
"mysql2": "*",
"sqlite3": "*"
"sqlite3": "*",
"tedious": "*"
},
"peerDependenciesMeta": {
"@libsql/client": {
Expand All @@ -91,6 +93,9 @@
"mysql2": {
"optional": true
},
"tedious": {
"optional": true
},
"@electric-sql/pglite": {
"optional": true
},
Expand Down
Loading