chore(sqlite): add Open() utility func
This commit is contained in:
@ -7,8 +7,19 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
"gitlab.com/wpetit/goweb/logger"
|
||||
|
||||
_ "modernc.org/sqlite"
|
||||
)
|
||||
|
||||
func Open(path string) (*sql.DB, error) {
|
||||
db, err := sql.Open("sqlite", path)
|
||||
if err != nil {
|
||||
return nil, errors.Wrapf(err, "could not open database with path '%s'", path)
|
||||
}
|
||||
|
||||
return db, nil
|
||||
}
|
||||
|
||||
func withTx(ctx context.Context, db *sql.DB, fn func(tx *sql.Tx) error) error {
|
||||
var tx *sql.Tx
|
||||
|
||||
|
Reference in New Issue
Block a user