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: mysql connector #86

Merged
merged 8 commits into from
Oct 9, 2024
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
2 changes: 1 addition & 1 deletion .env.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
POSTGRESQL_URL=postgresql://<user>:@localhost:5432/db0
MYSQL_URL=

# PlanetScale
PLANETSCALE_HOST=aws.connect.psdb.cloud
PLANETSCALE_USERNAME=username
PLANETSCALE_PASSWORD=password

1 change: 1 addition & 0 deletions docs/2.connectors/1.index.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Currently supported connectors:
- [LibSQL](/connectors/libsql)
- [PlanetScale](/connectors/planetscale)
- [PostgreSQL](/connectors/postgresql)
- [MySQL](/connectors/mysql)
- [SQLite](/connectors/sqlite)

::read-more{to="https://github.com/unjs/db0/issues/32"}
Expand Down
27 changes: 22 additions & 5 deletions docs/2.connectors/mysql.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,27 @@ icon: simple-icons:mysql

# MySQL

> Connect DB0 to Mysql Database
> Connect DB0 to Mysql Database using mysql2

:read-more{to="https://github.com/sidorares/node-mysql2"}
## Usage

::read-more{to="https://github.com/unjs/db0/issues/32"}
This connector is planned to be supported. Follow up via [unjs/db0#32](https://github.com/unjs/db0/issues/32).
::
For this connector, you need to install [`mysql2`](https://www.npmjs.com/package/mysql2) dependency:

:pm-install{name="mysql2"}

Use `mysql2` connector:

```js
import { createDatabase, sql } from "db0";
import mysql from "db0/connectors/mysql2";

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

## Options

:read-more{to="https://github.com/sidorares/node-mysql2/blob/master/typings/mysql/lib/Connection.d.ts#L82-L329"}
7 changes: 6 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@
"eslint": "^9.12.0",
"eslint-config-unjs": "^0.4.1",
"jiti": "^2.3.3",
"mysql2": "^3.11.3",
"pg": "^8.13.0",
"prettier": "^3.3.3",
"typescript": "^5.6.3",
Expand All @@ -74,7 +75,8 @@
"peerDependencies": {
"@libsql/client": "*",
"better-sqlite3": "*",
"drizzle-orm": "*"
"drizzle-orm": "*",
"mysql2": "*"
},
"peerDependenciesMeta": {
"@libsql/client": {
Expand All @@ -85,6 +87,9 @@
},
"drizzle-orm": {
"optional": true
},
"mysql2": {
"optional": true
}
},
"packageManager": "pnpm@9.12.1"
Expand Down
Loading