You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
469 B

  1. package initialize
  2. import (
  3. "fmt"
  4. "gin-vue-admin/global"
  5. "github.com/jinzhu/gorm"
  6. _ "github.com/jinzhu/gorm/dialects/sqlite"
  7. )
  8. //初始化数据库并产生数据库全局变量
  9. func Sqlite() {
  10. admin := global.GVA_CONFIG.Sqlite
  11. if db, err := gorm.Open("sqlite3", fmt.Sprintf("%s?%s", admin.Path,admin.Config)); err != nil {
  12. global.GVA_LOG.Error("DEFAULTDB数据库启动异常", err)
  13. } else {
  14. global.GVA_DB = db
  15. global.GVA_DB.LogMode(admin.LogMode)
  16. }
  17. }