2019-02-05 15:25:01 +03:00
|
|
|
package sqlite
|
2019-01-25 12:19:30 +03:00
|
|
|
|
|
|
|
import (
|
|
|
|
"database/sql"
|
2022-02-01 16:59:29 +03:00
|
|
|
|
|
|
|
_ "modernc.org/sqlite"
|
2019-01-25 12:19:30 +03:00
|
|
|
)
|
|
|
|
|
2019-02-05 15:25:01 +03:00
|
|
|
func New(filename string) (*Sqlite3Accessor, error) {
|
2022-02-01 16:59:29 +03:00
|
|
|
db, err := sql.Open("sqlite", filename+"?_timeout=500")
|
2019-01-25 12:19:30 +03:00
|
|
|
db.SetMaxOpenConns(1)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
sq := &Sqlite3Accessor{db: db, filename: filename}
|
|
|
|
return sq, nil
|
|
|
|
}
|