27 lines
614 B
Go
27 lines
614 B
Go
|
package db
|
||
|
|
||
|
import (
|
||
|
"database/sql"
|
||
|
|
||
|
_ "github.com/mattn/go-sqlite3"
|
||
|
)
|
||
|
|
||
|
var db *sql.DB
|
||
|
|
||
|
func init() {
|
||
|
var err error
|
||
|
db, err = sql.Open("sqlite3", "./bot.db")
|
||
|
if err != nil {
|
||
|
panic(err)
|
||
|
}
|
||
|
db.SetMaxOpenConns(1)
|
||
|
db.Exec("CREATE TABLE IF NOT EXISTS xp(id STRING NOT NULL UNIQUE, xp INTEGER NOT NULL)")
|
||
|
db.Exec("CREATE TABLE IF NOT EXISTS shard(id STRING NOT NULL UNIQUE, shard INTEGER NOT NULL)")
|
||
|
db.Exec("CREATE TABLE IF NOT EXISTS prestige(id STRING NOT NULL UNIQUE, multiplier INTEGER NOT NULL)")
|
||
|
db.Exec("CREATE TABLE IF NOT EXISTS starred(id STRING NOT NULL UNIQUE)")
|
||
|
}
|
||
|
|
||
|
func Close() {
|
||
|
db.Close()
|
||
|
}
|