govote/store/db.go
2024-05-14 10:27:13 +02:00

27 lines
456 B
Go

package store
import (
"database/sql"
_ "github.com/mattn/go-sqlite3"
)
// file points the the sqlite file.
const file = "./govote.db"
// db references the initialized sqlite connection.
var db *sql.DB
// init initialized the database layer
func init() {
var err error
if db, err = sql.Open("sqlite3", file); err != nil {
panic(err)
}
// initialize the sql schema
initCreateTables(db)
// initialize all prepared statements
initStmts(db)
}