v2-.jpg

package util

import (
    "gorm.io/driver/sqlite"
    "gorm.io/gorm"
)

func SQLiteTest() *gorm.DB {
    // github.com/mattn/go-sqlite3
    //db, err := gorm.Open(sqlite.Open("gorm.db"), &gorm.Config{})
    db, err := gorm.Open(sqlite.Open("file::memory:?cache=shared"), &gorm.Config{})
    if err != nil {
        panic("failed to connect database, err: " + err.Error())
    }
    return db
}

发表回复

您的电子邮箱地址不会被公开。

Captcha Code