Files
honoka-chan/pkg/db/db.go
T
YumeMichi 150ce674ad Implement more endpoints & overhaul [2/n]
Drop LevelDB and move all the things to SQLite.

Implemented endpoints:
/api <unit, accessoryMaterialAll>
/api <unit, accessoryTab>
/live/continue
/live/partyList
/unit/favoriteAccessory (WIP)
/unit/sale

Signed-off-by: Sean Du <do4suki@gmail.com>
2026-04-28 11:44:56 +08:00

40 lines
577 B
Go

package db
import (
_ "modernc.org/sqlite"
"xorm.io/xorm"
)
var (
MainDb = "assets/main.db"
UserDb = "assets/data.db"
MainEng *xorm.Engine
UserEng *xorm.Engine
)
func init() {
eng, err := xorm.NewEngine("sqlite", MainDb)
if err != nil {
panic(err)
}
err = eng.Ping()
if err != nil {
panic(err)
}
eng.SetMaxOpenConns(10)
eng.SetMaxIdleConns(5)
MainEng = eng
eng, err = xorm.NewEngine("sqlite", UserDb)
if err != nil {
panic(err)
}
err = eng.Ping()
if err != nil {
panic(err)
}
eng.SetMaxOpenConns(10)
eng.SetMaxIdleConns(5)
UserEng = eng
}