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

Method describeColumns

src/client/stdlib/sqlite.js:35–48  ·  view source on GitHub ↗
({schema, table} = {})

Source from the content-addressed store, hash-verified

33 );
34 }
35 async describeColumns({schema, table} = {}) {
36 if (table == null) throw new Error("missing table");
37 const rows = await this.query(
38 `SELECT name, type, "notnull" FROM pragma_table_info(?${schema == null ? "" : ", ?"}) ORDER BY cid`,
39 schema == null ? [table] : [table, schema]
40 );
41 if (!rows.length) throw new Error(`table not found: ${table}`);
42 return rows.map(({name, type, notnull}) => ({
43 name,
44 type: sqliteType(type),
45 databaseType: type,
46 nullable: !notnull
47 }));
48 }
49 async describe(object) {
50 const rows = await (object === undefined
51 ? this.query("SELECT name FROM sqlite_master WHERE type = 'table'")

Callers

nothing calls this directly

Calls 2

queryMethod · 0.95
sqliteTypeFunction · 0.85

Tested by

no test coverage detected