Insert into sqlite3 with better-sqlite3 not working

The drizzle logger out put:
Query: insert into "todos" ("id", "title", "completed", "created_at") values (null, ?, ?, ?) returning "id", "title", "completed", "created_at" -- params: ["asd", 0, 1706613150]
Query: insert into "todos" ("id", "title", "completed", "created_at") values (null, ?, ?, ?) returning "id", "title", "completed", "created_at" -- params: ["asd", 0, 1706613150]
Drizzle function call:
const x = await db
.insert(todos)
.values({
title: text,
createdAt: new Date(),
})
.returning()
.execute();
const x = await db
.insert(todos)
.values({
title: text,
createdAt: new Date(),
})
.returning()
.execute();
DB:
const sqlite = new Database(join(process.cwd(), "./db.sqlite"));
_db = drizzle(sqlite, {
schema,
logger: true,
});
const sqlite = new Database(join(process.cwd(), "./db.sqlite"));
_db = drizzle(sqlite, {
schema,
logger: true,
});
All seems good but no data being inserted into db, what might be wrong? Code here: https://github.com/Jokcy/solidstart-cf
GitHub
GitHub - Jokcy/solidstart-cf
Contribute to Jokcy/solidstart-cf development by creating an account on GitHub.
4 Replies
Angelelz
Angelelz5mo ago
I'm not sure you need to join your current path with ./db.sqlite You might be writing to another file without noticing
Jokcy
Jokcy5mo ago
But read and write are in the same instance, I can not read any records
Angelelz
Angelelz5mo ago
If you delete it, is it being created when you start the program?
Jokcy
Jokcy5mo ago
Worked after I delete the db file, don't know what happened though, THX anywary