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) {
|
2023-12-27 12:35:24 +03:00
|
|
|
db, err := sql.Open("sqlite", filename+"?_pragma=busy_timeout(30000)")
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
2019-01-25 12:19:30 +03:00
|
|
|
|
2023-12-27 12:35:24 +03:00
|
|
|
err = EnableWAL(db)
|
2019-01-25 12:19:30 +03:00
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
2023-12-27 12:35:24 +03:00
|
|
|
sq := &Sqlite3Accessor{db: db}
|
2019-01-25 12:19:30 +03:00
|
|
|
return sq, nil
|
|
|
|
}
|