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

Function insertSource

src/client/stdlib/duckdb.js:206–227  ·  view source on GitHub ↗
(database, name, source)

Source from the content-addressed store, hash-verified

204}
205
206async function insertSource(database, name, source) {
207 source = await source;
208 if (isFileAttachment(source)) return insertFile(database, name, source);
209 if (isArrowTable(source)) return insertArrowTable(database, name, source);
210 if (Array.isArray(source)) return insertArray(database, name, source);
211 if (isArqueroTable(source)) return insertArqueroTable(database, name, source);
212 if (typeof source === "string") return insertUrl(database, name, source);
213 if (source && typeof source === "object") {
214 if ("data" in source) {
215 // data + options
216 const {data, ...options} = source;
217 if (isArrowTable(data)) return insertArrowTable(database, name, data, options);
218 return insertArray(database, name, data, options);
219 }
220 if ("file" in source) {
221 // file + options
222 const {file, ...options} = source;
223 return insertFile(database, name, file, options);
224 }
225 }
226 throw new Error(`invalid source: ${source}`);
227}
228
229async function insertUrl(database, name, url) {
230 const connection = await database.connect();

Callers 2

registerTableFunction · 0.85
ofMethod · 0.85

Calls 8

isFileAttachmentFunction · 0.85
insertFileFunction · 0.85
isArrowTableFunction · 0.85
insertArrowTableFunction · 0.85
insertArrayFunction · 0.85
isArqueroTableFunction · 0.85
insertArqueroTableFunction · 0.85
insertUrlFunction · 0.85

Tested by

no test coverage detected