2022-07-06 23:19:05 +02:00
|
|
|
//go:build cgo
|
|
|
|
|
|
|
|
package core
|
|
|
|
|
|
|
|
import (
|
2022-12-11 17:32:56 +02:00
|
|
|
"github.com/pocketbase/dbx"
|
2022-12-15 16:42:35 +02:00
|
|
|
_ "github.com/mattn/go-sqlite3"
|
2022-07-06 23:19:05 +02:00
|
|
|
)
|
|
|
|
|
|
|
|
func connectDB(dbPath string) (*dbx.DB, error) {
|
2022-12-15 16:42:35 +02:00
|
|
|
db, err := dbx.Open("sqlite3", dbPath)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
2022-07-06 23:19:05 +02:00
|
|
|
}
|
|
|
|
|
2022-12-15 16:42:35 +02:00
|
|
|
if err := initPragmas(db); err != nil {
|
|
|
|
db.Close()
|
|
|
|
return nil, err
|
|
|
|
}
|
2022-07-06 23:19:05 +02:00
|
|
|
|
2022-12-15 16:42:35 +02:00
|
|
|
return db, nil
|
2022-07-06 23:19:05 +02:00
|
|
|
}
|