Make the memory database use a set name so it's safe to defer
This commit is contained in:
parent
d4148a4939
commit
1fb0d1c85a
8
main.go
8
main.go
|
@ -288,10 +288,16 @@ func main() {
|
||||||
}
|
}
|
||||||
}(conn)
|
}(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 {
|
if err != nil {
|
||||||
log.Fatalln("[FATAL] Cannot open session database:", err)
|
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 '?')")
|
_, 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 {
|
if err != nil {
|
||||||
|
|
Loading…
Reference in New Issue