mirror of https://github.com/rocboss/paopao-ce
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.
31 lines
656 B
31 lines
656 B
// Copyright 2022 ROC. All rights reserved.
|
|
// Use of this source code is governed by a MIT style
|
|
// license that can be found in the LICENSE file.
|
|
|
|
//go:build !cgo
|
|
// +build !cgo
|
|
|
|
package conf
|
|
|
|
import (
|
|
"database/sql"
|
|
|
|
"gorm.io/driver/sqlite"
|
|
"gorm.io/gorm"
|
|
_ "modernc.org/sqlite"
|
|
)
|
|
|
|
const (
|
|
sqlite3InCgoEnabled = false
|
|
)
|
|
|
|
func OpenSqlite3() (string, *sql.DB, error) {
|
|
db, err := sql.Open("sqlite", Sqlite3Setting.Dsn("sqlite"))
|
|
return "sqlite", db, err
|
|
}
|
|
|
|
func gormOpenSqlite3(opts ...gorm.Option) (*gorm.DB, error) {
|
|
dialector := &sqlite.Dialector{DriverName: "sqlite", DSN: Sqlite3Setting.Dsn("sqlite")}
|
|
return gorm.Open(dialector, opts...)
|
|
}
|