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.
paopao-ce/internal/conf/db_cgo.go

29 lines
576 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"
)
const (
sqlite3InCgoEnabled = true
)
func OpenSqlite3() (string, *sql.DB, error) {
db, err := sql.Open("sqlite3", Sqlite3Setting.Dsn("sqlite3"))
return "sqlite3", db, err
}
func gormOpenSqlite3(opts ...gorm.Option) (*gorm.DB, error) {
return gorm.Open(sqlite.Open(Sqlite3Setting.Dsn("sqlite3")), opts...)
}