Public
Back
Version 17
2/7/2024
import { sqlite } from "https://esm.town/v/std/sqlite";
const tablesQuery = await sqlite.execute(`select * from sqlite_schema`);
const tables = tab;
console.log(tables);
// let statements = [];
// for (const table of tables) {
// const schema = await sqlite.execute({
// sql: `SELECT name, sql FROM sqlite_schema WHERE name = '${table}'`,
// args: [],
// });
// const createStatement = schema.rows.map((row) => row.sql?.toString()) as string[];
// const data = await sqlite.execute(`select * from ${table}`);
// const importStatements = data.rows.map((row) => {
// const rowData = Object.entries(row).reduce(
// (obj, [key, value]) => ({ ...obj, [key]: value }),
// {},
// );
// return `insert into ${table} (${
// Object.keys(rowData).join(
// ", ",
// )
// }) values (${Object.values(rowData).join(", ")})`;
// });
// statements.push(...createStatement, ...importStatements);
// }
// const dumpTemplate = (statements: string[]) => {
// return `BEGIN TRANSACTION;
// ${statements.join(";\n")}
Updated: April 4, 2024