初学者,使用goframe框架的orm查询sqlite数据库,发生了以下错误
=== RUN TestORM
--- FAIL: TestORM (0.01s)
panic: unable to open database file: out of memory (14), SELECT * FROM `t_project` LIMIT 1 [recovered]
panic: unable to open database file: out of memory (14), SELECT * FROM `t_project` LIMIT 1
路径和数据库文件本身没有问题,使用"database/sql"这个包就可以正常查询到
gf v2.3.2
go1.17.11 windows/amd64
下面是代码
package utils
import (
"database/sql"
"fmt"
_ "github.com/gogf/gf/contrib/drivers/sqlite/v2"
"github.com/gogf/gf/v2/frame/g"
"github.com/gosnmp/gosnmp"
_ "github.com/mattn/go-sqlite3"
"golang.org/x/net/context"
"myapp/ZxtTool"
"strconv"
"testing"
"time"
)
func TestORM(*testing.T) {
ctx := context.Background()
one, err := g.DB("main").Model("t_project").One()
if err != nil {
panic(err)
}
defer g.DB("main").Close(ctx)
fmt.Println(one)
}
下面是config.yaml内的数据库配置
database:
main:
link: "sqlite::@file(E:/GoProject/myapp/flowData.db)"
Schema: "main"
有疑问加站长微信联系(非本文作者)