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

feat: MSSQL connector #121

Open
wants to merge 45 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
71f57b0
added tedious dependency
nick-w-nick Nov 9, 2024
f49f828
added mssql dialect
nick-w-nick Nov 9, 2024
7776b33
added mssql connector
nick-w-nick Nov 9, 2024
5c5213a
added mssql to connectors list
nick-w-nick Nov 9, 2024
318881d
added mssql-specific test table creation statement
nick-w-nick Nov 9, 2024
27af9a7
added mssql test suite
nick-w-nick Nov 9, 2024
e79283a
minor refactors
nick-w-nick Nov 9, 2024
8cb43bd
removed newline
nick-w-nick Nov 9, 2024
ed7b075
changed success property to be defined by the state of the query rath…
nick-w-nick Nov 9, 2024
a0f8194
replaced index access with deconstruction
nick-w-nick Nov 9, 2024
34d615d
removed rows from run result
nick-w-nick Nov 9, 2024
5d51c5c
removed error prefix
nick-w-nick Nov 9, 2024
9474692
replaced shortened variable name
nick-w-nick Nov 9, 2024
b37749d
moved utility functions outside of connector
nick-w-nick Nov 9, 2024
00c3753
swapped query parameters to be provided via object rather than array
nick-w-nick Nov 9, 2024
ad45fa7
added clarifying comment
nick-w-nick Nov 9, 2024
d6d9fb6
removed unnecessary return
nick-w-nick Nov 9, 2024
f9afd4d
added example MSSQL env vars
nick-w-nick Nov 9, 2024
3d2e6ea
moved utilities to bottom of file for prioritization
nick-w-nick Nov 9, 2024
8e20159
updated supported connectors list
nick-w-nick Nov 9, 2024
0498d64
added mssql doc page
nick-w-nick Nov 9, 2024
c733c00
deleted test file
nick-w-nick Nov 9, 2024
e3cdb33
fixed typo
nick-w-nick Nov 9, 2024
6c59dab
remove type module
nick-w-nick Nov 11, 2024
815c669
replaced iterator condition
nick-w-nick Nov 11, 2024
7ea76fd
chore: apply automated updates
autofix-ci[bot] Nov 11, 2024
58a7748
Merge remote-tracking branch 'upstream/main'
nick-w-nick Nov 14, 2024
c50498f
added peer dep meta entry
nick-w-nick Nov 14, 2024
13c38cd
updated directory structure to allow utilities to be exported separately
nick-w-nick Nov 14, 2024
c9aae00
fixed parameter typing
nick-w-nick Nov 14, 2024
dccba54
added tests for mssql utility functions
nick-w-nick Nov 14, 2024
fe98eab
updated import to test default export directly
nick-w-nick Nov 14, 2024
d016bdc
added test to cover default function behavior
nick-w-nick Nov 14, 2024
b1a9d99
Merge remote-tracking branch 'upstream/main'
nick-w-nick Dec 2, 2024
53949b4
swapped DateTime for DateTime2 for better future proofing
nick-w-nick Dec 9, 2024
389fd0c
swapped datetime value in test
nick-w-nick Dec 9, 2024
c500e34
Merge remote-tracking branch 'upstream/main'
nick-w-nick Jan 11, 2025
8de0299
Merge remote-tracking branch 'upstream/main'
nick-w-nick Jan 28, 2025
c263085
chore: apply automated updates
autofix-ci[bot] Jan 28, 2025
1f657ab
moved mssql connector to single file for consistency
nick-w-nick Jan 28, 2025
59ee050
updated gen connectors script to include options name whitelist for n…
nick-w-nick Jan 28, 2025
756687d
regenerated _connectors
nick-w-nick Jan 28, 2025
cffb85b
Merge branch 'main' of https://github.com/nick-w-nick/db0
nick-w-nick Jan 28, 2025
48f229e
updated test imports
nick-w-nick Jan 28, 2025
f8c9ddc
removed custom export
nick-w-nick Jan 28, 2025
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 @@ -5,3 +5,10 @@ MYSQL_URL=
PLANETSCALE_HOST=aws.connect.psdb.cloud
PLANETSCALE_USERNAME=username
PLANETSCALE_PASSWORD=password

# MSSQL
MSSQL_HOST=localhost
MSSQL_PORT=1433
MSSQL_USERNAME=sa
MSSQL_PASSWORD=password
MSSQL_DB_NAME=test_db
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 @@ -73,6 +73,7 @@
"pg": "^8.13.1",
"prettier": "^3.4.2",
"scule": "^1.3.0",
"tedious": "^18.6.1",
"typescript": "^5.7.3",
"unbuild": "^3.3.1",
"vitest": "^3.0.4"
Expand All @@ -83,7 +84,8 @@
"better-sqlite3": "*",
"drizzle-orm": "*",
"mysql2": "*",
"sqlite3": "*"
"sqlite3": "*",
"tedious": "*"
},
"peerDependenciesMeta": {
"@libsql/client": {
Expand All @@ -98,6 +100,9 @@
"mysql2": {
"optional": true
},
"tedious": {
"optional": true
},
"@electric-sql/pglite": {
"optional": true
},
Expand Down
Loading