[feature]:支持Sqlite数据库 (#1467)

* add sqlite3 support

* 修改gorm.io/driver/sqlite 为 github.com/glebarez/sqlite 适配windows用户无cgo环境

---------

Co-authored-by: Kafumio <linzehong1_2020@qq.com>
Co-authored-by: Kafumio <73083337+Kafumio@users.noreply.github.com>
Co-authored-by: sliverhorn <sliver_horn@qq.com>
This commit is contained in:
奇淼(piexlmax
2023-06-30 19:18:20 +08:00
committed by GitHub
co-authored by Kafumio Kafumio sliverhorn
parent 7ababb626b
commit bd3931d62d
17 changed files with 366 additions and 33 deletions
+4 -1
View File
@@ -14,6 +14,7 @@ import (
const (
Mysql = "mysql"
Pgsql = "pgsql"
Sqlite = "sqlite"
InitSuccess = "\n[%v] --> 初始数据成功!\n"
InitDataExist = "\n[%v] --> %v 的初始数据已存在!\n"
InitDataFailed = "\n[%v] --> %v 初始数据失败! \nerr: %+v\n"
@@ -102,6 +103,9 @@ func (initDBService *InitDBService) InitDB(conf request.InitDB) (err error) {
case "pgsql":
initHandler = NewPgsqlInitHandler()
ctx = context.WithValue(ctx, "dbtype", "pgsql")
case "sqlite":
initHandler = NewSqliteInitHandler()
ctx = context.WithValue(ctx, "dbtype", "sqlite")
default:
initHandler = NewMysqlInitHandler()
ctx = context.WithValue(ctx, "dbtype", "mysql")
@@ -161,7 +165,6 @@ func createTables(ctx context.Context, inits initSlice) error {
} else {
next = n
}
}
return nil
}