English | ç®€ä½“ä¸æ–‡
Profile DuckDB tables and export the results as offline HTML reports.
From the repository root, install the dependencies with Node.js 22.13 or later.
npm installSave the example as profile-orders.mjs in the repository root and run node profile-orders.mjs.
import { writeFile } from 'node:fs/promises';
import { DuckDBInstance } from '@duckdb/node-api';
import { profile } from 'data_profiling';
import { renderReport } from 'data_profiling/report';
const database = await DuckDBInstance.create(':memory:');
let connection;
try {
connection = await database.connect();
await connection.run(`
CREATE TABLE orders AS
SELECT * FROM (VALUES
(1, 120.00, 'web'),
(2, 80.50, 'store'),
(3, NULL, 'web'),
(4, 42.00, NULL)
) AS sample(order_id, amount, channel)
`);
const results = await profile({ connection, table: 'orders' });
await writeFile('orders-report.html', renderReport(results, {
title: 'Orders profile',
language: 'en-US',
}));
} finally {
connection?.closeSync();
database.closeSync();
}Open orders-report.html in a browser. renderReport() takes the records from profile() and optional display settings for the title, theme, and language.
profile() takes an existing DuckDB connection and a required table string. Use a table or view name DuckDB can resolve, such as 'orders' or 'sales.orders'.
columns, metrics, types, orderBy, and timeIndex apply to the selected table or view. When columns is omitted, profile() reads the column definitions from DuckDB. Configuration reference
profile() now defaults to BASIC_METRICS. Pass metrics: ALL_METRICS to request the full catalog, or select the metrics your report needs.
Future batch profiling and cross-table statistics will use separate entry points.
After installing the library, run these commands from the repository root.
npm --prefix site install
npm --prefix site run devThe browser passes a DuckDB-Wasm connection to profile().
Run npm --prefix site run full and open the local playground. Select the local full mode, then set the column roles and time index for your data. To enable file and image statistics for uploaded datasets, pass the directory the engine can read with npm --prefix site run full -- /path/to/files.