Documentation
¶
Index ¶
Constants ¶
View Source
const (
DEFAULT_BUSY_TIMEOUT = 10 * 1000 // 10 seconds in milliseconds
)
Variables ¶
This section is empty.
Functions ¶
func ConnectToDatabase ¶
func ConnectToDatabase(cfg *ConnectionConfig) (*relational.DB, error)
ConnectToDatabase - Opens a SQLite database file with the given configuration, creating the file and its parent directories if they don't exist. Connections use WAL journaling with a busy timeout so a writer and concurrent readers can share the file.
func ConnectToMemoryDatabase ¶
func ConnectToMemoryDatabase() (*relational.DB, error)
ConnectToMemoryDatabase - Opens an in-memory SQLite database, useful for tests. The pool is pinned to a single connection because each new connection to an in-memory database would otherwise see its own empty database.
Types ¶
type ConnectionConfig ¶
type ConnectionConfig struct {
Path string `mapstructure:"path"`
BusyTimeout int `mapstructure:"busyTimeout"`
// MaxOpenConns caps the connection pool. SQLite allows a single writer
// at a time, so setting this to 1 serializes access in the pool instead
// of relying on busy timeout retries. 0 leaves the pool unlimited.
MaxOpenConns int `mapstructure:"maxOpenConns"`
Verbose bool `mapstructure:"verbose"`
}
Click to show internal directories.
Click to hide internal directories.