mirror of
http://github.com/goal-web/database
synced 2025-12-24 10:40:53 +08:00
24 lines
565 B
Go
24 lines
565 B
Go
package drivers
|
|
|
|
import (
|
|
"github.com/goal-web/contracts"
|
|
"github.com/goal-web/supports/logs"
|
|
"github.com/goal-web/supports/utils"
|
|
"github.com/jmoiron/sqlx"
|
|
_ "github.com/mattn/go-sqlite3"
|
|
)
|
|
|
|
type Sqlite struct {
|
|
*Base
|
|
}
|
|
|
|
func SqliteConnector(config contracts.Fields, events contracts.EventDispatcher) contracts.DBConnection {
|
|
db, err := sqlx.Connect("sqlite3", utils.GetStringField(config, "database"))
|
|
|
|
if err != nil {
|
|
logs.WithError(err).WithField("config", config).Fatal("sqlite 数据库初始化失败")
|
|
}
|
|
|
|
return &Sqlite{NewDriver(db, events)}
|
|
}
|