Using external DuckDB Connection
Cosmograph supports external DuckDB connections for points and links data. You can pass points and links as strings representing existing table names with related data. When provided as strings, the custom DuckDB connection fetches relevant data from these specified tables from external DuckDB instance.
Note: Ensure that
pointsandlinkstables are prepared in the appropriate Cosmograph format and contain required columns.
duckDBConnection
string | {
duckdb: AsyncDuckDB;
connection?: AsyncDuckDBConnection
}The connection string or WasmDuckDBConnection object with instance of the DuckDB database with its connection.
Here are examples of how to provide a custom DuckDB connection into Cosmograph:
// Assuming you have a DuckDB-Wasm instance with data somewhere
// const db = new duckdb.AsyncDuckDB(logger, worker)
// const connection = await db.connect()
const [config, setConfig] = useState({
points: 'existing_points_table',
links: 'existing_links_table',
pointIdBy: 'id',
pointIndexBy: 'idx',
linkSourceBy: 'source',
linkSourceIndexBy: 'sourceidx',
linkTargetBy: 'target',
linkTargetIndexBy: 'targetidx',
})
return (
<Cosmograph
duckDBConnection={{ duckdb: db, connection: connection }}
{...config}
/>
)