mirror of
https://github.com/langchain-ai/docs.git
synced 2026-08-27 02:41:59 -04:00
24 lines
616 B
Plaintext
24 lines
616 B
Plaintext
```ts
|
|
import sqlite3 from "sqlite3";
|
|
|
|
// Below are minimal tools for demonstration purposes.
|
|
async function runQuery(query: string): Promise<any[]> {
|
|
const dbPath = await resolveDbPath();
|
|
const db = new sqlite3.Database(dbPath);
|
|
return new Promise((resolve, reject) => {
|
|
db.all(query, [], (err, rows) => {
|
|
db.close();
|
|
if (err) reject(err);
|
|
else resolve(rows);
|
|
});
|
|
});
|
|
}
|
|
|
|
async function getSchema() {
|
|
const tables = await runQuery(
|
|
"SELECT sql FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%';",
|
|
);
|
|
return tables.map((row) => row.sql).join("\n\n");
|
|
}
|
|
```
|