mapserver/mapobjectdb/sqlite/new.go

23 lines
344 B
Go
Raw Normal View History

2019-02-05 15:25:01 +03:00
package sqlite
2019-01-25 12:19:30 +03:00
import (
"database/sql"
_ "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) {
db, err := sql.Open("sqlite", filename+"?_pragma=busy_timeout(30000)")
if err != nil {
return nil, err
}
2019-01-25 12:19:30 +03:00
err = EnableWAL(db)
2019-01-25 12:19:30 +03:00
if err != nil {
return nil, err
}
sq := &Sqlite3Accessor{db: db}
2019-01-25 12:19:30 +03:00
return sq, nil
}