Open creates a new SQLite database connection.
(dsn string)
| 18 | |
| 19 | // Open creates a new SQLite database connection. |
| 20 | func Open(dsn string) (*sql.DB, error) { |
| 21 | if dsn == ":memory:" { |
| 22 | dsn = "file::memory:?cache=shared&_pragma=journal_mode(WAL)" |
| 23 | } |
| 24 | db, err := sql.Open("sqlite", dsn) |
| 25 | if err != nil { |
| 26 | return nil, err |
| 27 | } |
| 28 | db.SetMaxOpenConns(1) // SQLite single-writer |
| 29 | return db, nil |
| 30 | } |
| 31 | |
| 32 | func NewSQLiteStore(db *sql.DB) *SQLiteStore { |
| 33 | return &SQLiteStore{db: db} |
no outgoing calls