fix: sqlite3 并发之后被 lock 的问题 (#162)

This commit is contained in:
二丫讲梵 2023-03-08 20:14:07 +08:00 committed by GitHub
parent 69da830de9
commit b78ff04475
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 0 deletions

View File

@ -46,6 +46,12 @@ func ConnSqlite() *gorm.DB {
if err != nil { if err != nil {
Log.Panicf("failed to connect sqlite3: %v", err) Log.Panicf("failed to connect sqlite3: %v", err)
} }
dbObj, err := db.DB()
if err != nil {
Log.Panicf("failed to get sqlite3 obj: %v", err)
}
// 参见: https://github.com/glebarez/sqlite/issues/52
dbObj.SetMaxOpenConns(1)
return db return db
} }