TiDB Serverless is compatible with MySQL, so you can use MySQL connection guide to connect to it.
Waddler <> TiDB Serverless
This guide assumes familiarity with:
- Database connection basics with Waddler
- TiDB database - website
- TiDB HTTP Driver - website
- Waddler MySQL drivers - docs
According to the official website, TiDB Serverless is a fully-managed, autonomous DBaaS with split-second cluster provisioning and consumption-based pricing.
TiDB Serverless provides an HTTP driver for edge environments. It is natively supported by Waddler via waddler/tidb-serverless
package.
Step 1 - Install packages
npm
yarn
pnpm
bun
npm i waddler @tidbcloud/serverless
Step 2 - Initialize the driver and make a query
import { waddler } from 'waddler/tidb-serverless';
const sql = waddler({ connection: { url: process.env.TIDB_URL }});
const result = await sql`select 1;`;
If you need to provide your existing driver:
import { connect } from '@tidbcloud/serverless';
import { waddler } from 'waddler/tidb-serverless';
const client = connect({ url: process.env.TIDB_URL });
const sql = waddler({ client });
const result = await sql`select 1;`;