change to better sqlite3

This commit is contained in:
Darius
2026-03-05 18:15:22 +01:00
parent 2dd3805a54
commit 2749ebef2b
3 changed files with 379 additions and 4 deletions

View File

@@ -1,5 +1,5 @@
import { watchFile } from "node:fs";
import { DatabaseSync } from "node:sqlite";
import Database from "better-sqlite3";
export type StepRow = {
date: string;
@@ -7,7 +7,7 @@ export type StepRow = {
};
export class GadgetbridgeClient {
private db: DatabaseSync;
private db: Database.Database;
private readonly dbPath: string;
private readonly oldDbPath: string;
@@ -23,8 +23,8 @@ export class GadgetbridgeClient {
});
}
private openDb(): DatabaseSync {
const db = new DatabaseSync(this.dbPath, { open: true });
private openDb(): Database.Database {
const db = new Database(this.dbPath, { readonly: true });
db.exec(`ATTACH DATABASE '${this.oldDbPath}' AS old`);
return db;
}