Make the memory database use a set name so it's safe to defer

This commit is contained in:
Tracker-Friendly 2024-07-21 09:03:32 +01:00
parent d4148a4939
commit 1fb0d1c85a
1 changed files with 7 additions and 1 deletions

View File

@ -288,10 +288,16 @@ func main() {
}
}(conn)
mem, err = sql.Open("sqlite3", ":memory:?cache=shared&mode=memory")
mem, err = sql.Open("sqlite3", "file:bgnsessiondb?cache=shared&mode=memory")
if err != nil {
log.Fatalln("[FATAL] Cannot open session database:", err)
}
defer func(mem *sql.DB) {
err := mem.Close()
if err != nil {
log.Println("[ERROR] Unknown in main() mem defer:", err)
}
}(mem)
_, err = mem.Exec("CREATE TABLE sessions (sessionid INTEGER PRIMARY KEY AUTOINCREMENT, session TEXT NOT NULL, id INTEGER NOT NULL, device TEXT NOT NULL DEFAULT '?')")
if err != nil {