Spaces:
Sleeping
Sleeping
Download src/lib/db.ts from PITTI/speechmap-judges: direct link, hf CLI and curl.
- Browser
- Download file 572 Bytes
-
https://huggingface.co/spaces/PITTI/speechmap-judges/resolve/main/src/lib/db.ts
- Command line
-
hf download hf://spaces/PITTI/speechmap-judges/src/lib/db.ts
-
curl -L -o db.ts https://huggingface.co/spaces/PITTI/speechmap-judges/resolve/main/src/lib/db.ts
572 Bytes
| import duckdb from 'duckdb'; | |
| import path from 'path'; | |
| const ROOT_DIR = process.cwd(); // cwd() = Current Working Directory | |
| const dbPath = path.join(ROOT_DIR, 'database.duckdb'); | |
| const db = new duckdb.Database(dbPath, { "access_mode": "READ_ONLY" }); | |
| console.log(`DuckDB connected in READ_ONLY mode at ${dbPath}`); | |
| function query<T>(sql: string, ...params: any[]): Promise<T[]> { | |
| return new Promise((resolve, reject) => { | |
| db.all(sql, ...params, (err, res) => { | |
| if (err) return reject(err); | |
| resolve(res as T[]); | |
| }); | |
| }); | |
| } | |
| export default { query }; |