📣
TiDB Cloud Premium is now in public preview. Unlimited growth, instant elasticity, advanced security for enterprise workloads. Try it out →

Connect to TiDB Cloud Lake Using Node.js



The official Node.js driver provides TypeScript support and Promise-based API for modern JavaScript applications.

Installation

npm install tidbcloudlake-driver

Connection String: See driver overview for DSN format and examples.


Key Features

  • TypeScript Support: Full TypeScript definitions included
  • Promise-based API: Modern async/await support
  • Streaming Results: Efficient handling of large result sets
  • Connection Pooling: Built-in connection management

Data Type Mappings

TiDB Cloud LakeNode.jsNotes
Basic Types
BOOLEANboolean
TINYINTnumber
SMALLINTnumber
INTnumber
BIGINTnumber
FLOATnumber
DOUBLEnumber
DECIMALstringPrecision preserved
STRINGstring
Date/Time
DATEDate
TIMESTAMPDate
Complex Types
ARRAY(T)Array
TUPLE(...)Array
MAP(K,V)Object
VARIANTstringJSON encoded
BINARYBuffer
BITMAPstringBase64 encoded

Basic Usage

const { Client } = require('tidbcloudlake-driver'); // Connect to TiDB Cloud Lake const client = new Client('<your-dsn>'); const conn = await client.getConn(); // DDL: Create table await conn.exec(`CREATE TABLE users ( id INT, name STRING, email STRING )`); // Write: Insert data await conn.exec("INSERT INTO users VALUES (?, ?, ?)", [1, "Alice", "alice@example.com"]); // Query: Select data const rows = await conn.queryIter("SELECT id, name, email FROM users WHERE id = ?", [1]); for await (const row of rows) { console.log(row.values()); } conn.close();

Resources

Was this page helpful?