{"id":50105008,"url":"https://github.com/perryts/mysql","last_synced_at":"2026-05-23T10:01:35.686Z","repository":{"id":356012703,"uuid":"1230639642","full_name":"PerryTS/mysql","owner":"PerryTS","description":"Pure-TypeScript MySQL/MariaDB wire-protocol driver. Runs on Node.js and Bun, AOT-compiles to a native binary via Perry. Zero native dependencies.","archived":false,"fork":false,"pushed_at":"2026-05-21T17:00:59.000Z","size":153,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-05-21T23:59:45.428Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/PerryTS.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-05-06T07:21:23.000Z","updated_at":"2026-05-21T17:01:17.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/PerryTS/mysql","commit_stats":null,"previous_names":["perryts/mysql"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/PerryTS/mysql","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerryTS%2Fmysql","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerryTS%2Fmysql/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerryTS%2Fmysql/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerryTS%2Fmysql/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/PerryTS","download_url":"https://codeload.github.com/PerryTS/mysql/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/PerryTS%2Fmysql/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33390972,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-23T04:15:53.637Z","status":"ssl_error","status_checked_at":"2026-05-23T04:15:53.242Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-05-23T10:01:33.434Z","updated_at":"2026-05-23T10:01:35.679Z","avatar_url":"https://github.com/PerryTS.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @perryts/mysql\n\nPure-TypeScript MySQL / MariaDB wire-protocol driver. Runs on Node.js and\nBun, and ahead-of-time compiles to a native binary via\n[Perry](https://github.com/PerryTS/perry) (LLVM). Zero native dependencies.\n\nSibling package of\n[@perryts/postgres](https://github.com/PerryTS/postgres).\n\n## Status\n\nv0.1 — **all milestones shipped**:\n\n- [x] M1: Packet framing (3-byte length + seq id, \u003e16 MB chains) + lenenc codecs\n- [x] M2: HandshakeV10 + HandshakeResponse41 + `COM_QUERY`\n- [x] M3: Auth plugins (`mysql_native_password`, `caching_sha2_password`,\n        `sha256_password`, `mysql_clear_password`, MariaDB `client_ed25519`)\n        + mid-handshake auth-switch\n- [x] M4: Prepared protocol: `COM_STMT_PREPARE` / `EXECUTE` / `CLOSE` +\n        per-connection prepared cache + binary-resultset decoder\n- [x] M5: Rich type codecs — `Decimal`, `MyDate` / `MyTime` / `MyDateTime`,\n        23 built-ins + `registerType()` extension point\n- [x] M6: TLS (`SSLRequest` + `sslmode`), `Pool`, `Connection.cancel()`\n        via `KILL QUERY`, `sql\\`\\`` template, `parseConnectionString`,\n        `resolveConnectOptions`\n- [x] M7: Multi-resultset (`resultSets` on `QueryResult`), LOCAL_INFILE\n        refusal by default, benchmark harness, smoke examples\n\n## Quickstart\n\n```ts\nimport { connect } from '@perryts/mysql';\n\nconst conn = await connect({\n    host: '127.0.0.1',\n    port: 3306,\n    user: 'root',\n    password: 'secret',\n    database: 'test',\n});\n\nconst result = await conn.query('SELECT ? + ? AS sum', [40, 2]);\nconsole.log(result.rows); // [ { sum: 42 } ]\n\nawait conn.close();\n```\n\n## Testing\n\n```sh\nbun run verify       # typecheck + bun test + node TLS tests + build\nbun test             # 135 unit + integration tests against mock server\nbun run test:tls:node  # TLS mid-stream upgrade under Node (Bun stalls on tls.connect({socket}))\nbun run test:real    # docker MySQL 8 + MariaDB 11 integration matrix\n```\n\n## Benchmarks\n\nHeadlines from [bench/RESULTS.md](bench/RESULTS.md) (MySQL 8.0.45 over WAN,\n30-50 iterations, median ms per query):\n\n| Workload | Bun + @perryts/mysql | Bun + mysql2 | Node + @perryts/mysql | Node + mysql2 | Perry AOT + @perryts/mysql |\n|---|---:|---:|---:|---:|---:|\n| `SELECT 1` (text)        | **96.6** | 485.8 | **84.1** | 80.5 | **67.0** |\n| `SELECT ? AS v` (prep)   | **69.3** | 181.0 | 89.7 | **68.6** | **80.0** |\n| `SELECT * LIMIT 1000`    | **96.1** | 112.8 | **113.9** | 99.2 | 122.5 |\n| `SELECT * LIMIT 10000`   | **330.4** | 457.9 | **567.8** | 475.9 | — |\n\n- **5-7× faster than `mysql2` under Bun** on small queries (`mysql2`'s\n  warm-up under Bun is sub-optimal; this driver doesn't have that\n  cliff).\n- **Comparable to `mysql2` under Node** at the median across all\n  workloads — within 20% on every row.\n- **Perry AOT wins `SELECT 1` outright** at 32 ms min, brushing the\n  WAN floor of ~30 ms.\n- **Best median on 10k-row results under Bun** (330 ms vs `mysql2`'s\n  458 ms), though Bun has a long p95 tail driven by GC on large row\n  objects — see notes in `bench/RESULTS.md`.\n\n### Reproducing\n\n```sh\n(cd bench \u0026\u0026 bun install)  # pulls mysql2 / mysql into bench/node_modules only\nMYSQL_HOST=127.0.0.1 MYSQL_TCP_PORT=33306 MYSQL_USER=... \\\n  bash bench/run-all.sh    # runs @perryts/mysql, mysql2, mysql legacy side by side\n```\n\n## Design notes\n\n- No `pg`-style OIDs: MySQL identifies types via a single `MYSQL_TYPE_*`\n  byte + a 2-byte flag field. Codecs key on those.\n- Binary protocol for parameterised queries, text protocol for parameter-less.\n- Rows returned as `{ fields, rows, rowsArray, rowsRaw, command, rowCount }`\n  (raw bytes for GUI consumers + decoded objects for ergonomics).\n- Zero dependencies at runtime. `mysql2` / `mysql` are dev-only (bench only).\n\n## License\n\nMIT.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperryts%2Fmysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fperryts%2Fmysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fperryts%2Fmysql/lists"}