DBDelve
Dive deep into your data. A fast, native, multi-engine database client written in Rust. Free and open source, no telemetry.
翻訳待ち
Unified Arrow Flight and Flight SQL client for JavaScript and TypeScript runtimes.
翻訳待ち
Loading the full README.
Read the full README ↗Unified Arrow Flight and Flight SQL client for JavaScript and TypeScript runtimes. Provides complete gRPC client support for Apache Arrow Flight and Flight SQL protocols.
bun add @qualithm/arrow-flight-client
# or
npm install @qualithm/arrow-flight-client
import { createFlightClient, decodeFlightDataToTable } from "@qualithm/arrow-flight-client"
const client = createFlightClient({
url: "http://localhost:50051",
auth: { type: "bearer", token: "your-token" }
})
// List available flights
for await (const info of client.listFlights()) {
console.log(info.flightDescriptor?.path)
}
// Fetch data
const flightInfo = await client.getFlightInfo({ type: "path", path: ["my", "dataset"] })
const ticket = flightInfo.endpoint[0]?.ticket
if (ticket === undefined) throw new Error("flight has no ticket")
const table = await decodeFlightDataToTable(client.doGet(ticket))
console.log(`Received ${table.numRows} rows`)
client.close()
import { createFlightSqlClient } from "@qualithm/arrow-flight-client"
const client = createFlightSqlClient({
url: "http://localhost:50051",
auth: { type: "bearer", token: "your-token" }
})
// Execute a query
const table = await client.query("SELECT * FROM users LIMIT 10")
console.log(`Got ${table.numRows} rows`)
// Stream large results
for await (const batch of client.queryBatches("SELECT * FROM large_table")) {
console.log(`Batch: ${batch.numRows} rows`)
}
// Prepared statements
const stmt = await client.prepare("SELECT * FROM users WHERE id = ?")
const result = await client.executePrepared(stmt)
await client.closePreparedStatement(stmt)
// Transactions
const txn = await client.beginTransaction()
try {
await client.executeUpdate("INSERT INTO users (name) VALUES ('Alice')", {
transactionId: txn.id
})
await client.commit(txn)
} catch {
await client.rollback(txn)
}
// Database metadata
const catalogs = await client.getCatalogs()
const schemas = await client.getDbSchemas({})
const tables = await client.getTables({})
client.close()
const client = createFlightClient({
url: "https://flight-server:50051",
auth: { type: "bearer", token: "your-api-token" }
})
const client = createFlightClient({
url: "https://flight-server:50051",
auth: {
type: "basic",
credentials: { username: "user", password: "pass" }
}
})
// Authenticate (performs Flight Handshake RPC)
await client.authenticate()
For credentials that expire or rotate, supply an authProvider instead of a static auth. The
client resolves credentials through it before the first request and again whenever the server
rejects a call as unauthenticated, so a long-lived client picks up a rotation without being
reconstructed.
const client = createFlightClient({
url: "https://flight-server:50051",
authProvider: async () => ({
type: "bearer",
token: await fetchFreshToken()
})
})
The resolved credential is cached, so the provider is not consulted per request. A rejected call is retried once with fresh credentials; if it is rejected again the error is surfaced. Concurrent rejections share a single refresh.
Two calls are not retried: doPut, because its input stream has already been partly consumed and
cannot be replayed, and any server stream that had already delivered a message before the rejection,
which would otherwise repeat its opening messages. Both surface FlightAuthError for the caller to
retry.
import { readFileSync } from "node:fs"
const client = createFlightClient({
url: "https://flight-server:50051",
tls: {
ca: readFileSync("ca.pem"),
cert: readFileSync("client.pem"),
key: readFileSync("client-key.pem")
}
})
import {
encodeTableToFlightData,
decodeFlightDataToTable,
decodeFlightDataStream
} from "@qualithm/arrow-flight-client"
import { tableFromArrays } from "apache-arrow"
// Create Arrow data
const table = tableFromArrays({
id: Int32Array.from([1, 2, 3]),
name: ["Alice", "Bob", "Charlie"]
})
// Encode for upload
const flightData = encodeTableToFlightData(table)
// Decode a stream
const receivedTable = await decodeFlightDataToTable(flightData)
// Stream batches
for await (const batch of decodeFlightDataStream(encodeTableToFlightData(table))) {
console.log(`Batch: ${batch.numRows} rows`)
}
This is the beginning of the README. Read the rest at the original. Read the full README ↗