MCPcopy Create free account
hub / github.com/observablehq/framework / registerExtensions

Function registerExtensions

src/client/stdlib/duckdb.js:189–204  ·  view source on GitHub ↗
(db, extensions)

Source from the content-addressed store, hash-verified

187Object.defineProperty(DuckDBClient.prototype, "dialect", {value: "duckdb"});
188
189async function registerExtensions(db, extensions) {
190 const {mainModule} = await bundle;
191 const platform = Object.keys(bundles).find((platform) => mainModule === bundles[platform].mainModule);
192 const con = await db.connect();
193 try {
194 await Promise.all(
195 Object.entries(DUCKDB_MANIFEST.extensions).map(([name, {load, [platform]: ref}]) =>
196 con
197 .query(`INSTALL "${name}" FROM '${import.meta.resolve(ref)}'`)
198 .then(() => (extensions === undefined ? load : extensions.includes(name)) && con.query(`LOAD "${name}"`))
199 )
200 );
201 } finally {
202 await con.close();
203 }
204}
205
206async function insertSource(database, name, source) {
207 source = await source;

Callers 1

ofMethod · 0.85

Calls 3

findMethod · 0.80
queryMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected