| name | tidbx-javascript-mysqljs |
| description | Connect to TiDB from JavaScript/Node.js using the mysqljs/mysql driver (npm package: mysql). Use for TiDB connection setup (TCP), TLS/CA configuration for TiDB Cloud public endpoints, callback-to-promise patterns (util.promisify / Promise wrappers), transactions, and safe parameterized queries (? placeholders) with small runnable connection/CRUD templates. |
TiDB + JavaScript (mysqljs/mysql)
Use this skill to connect to TiDB from Node.js with the mysql package (aka mysqljs/mysql), configure TLS correctly for TiDB Cloud, and provide small runnable snippets you can copy into a project.
Important: mysql vs mysql2
These two drivers are easy to mix up:
- This skill is for mysqljs/mysql (
npm i mysql) which is primarily callback-based.
- If you want the promise-native driver mysql2 (
npm i mysql2 / mysql2/promise), jump to the tidbx-javascript-mysql2 skill instead.
Recommendation: prefer an ORM for app code
For most application code (models, migrations, types), prefer an ORM/query builder:
- Prisma ORM: use
tidbx-prisma
- Kysely query builder: use
tidbx-kysely
When to use this skill
- Connect to TiDB from JavaScript/TypeScript (Node.js runtime) via
mysql (mysqljs/mysql).
- Need TLS guidance (TiDB Cloud public endpoint) or CA certificate setup (TiDB Cloud Dedicated).
- Want a minimal "connect -> SELECT VERSION() -> CRUD" template using mysqljs/mysql.
Code generation rules (Node.js)
- Never hardcode credentials; use
DATABASE_URL or TIDB_* env vars.
- Use parameterized queries with placeholders; never string-concatenate untrusted input.