sqlite3_db

package
v0.14.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 3, 2025 License: BSD-3-Clause Imports: 5 Imported by: 18

Documentation

Overview

Package sqlite3_db contains common types and functions for storing data in a sqlite3 database.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DateToString

func DateToString(t time.Time) string

DateToString converts a date to YYYYmmdd

func NewDoer

func NewDoer(db *Db) db.Doer

func StringToDate

func StringToDate(s string) (t time.Time, e error)

StringToDate converts a string of form YYYYmmdd to a time object in UTC time zone.

Types

type Action

type Action func(tx *sql.Tx) error

Action represents some action against a sqlite3 database

type Db

type Db struct {
	// contains filtered or unexported fields
}

Db wraps a sqlite3 database connection. With Db, multiple goroutines can safely share the same connection. Db also provides transactional behavior.

func New

func New(db *sql.DB) *Db

New creates a new Db.

func (*Db) Close

func (d *Db) Close() error

Close closes the underlying sql.DB instance.

func (*Db) Do

func (d *Db) Do(action Action) error

Do performs action within a transaction.

type Doer

type Doer interface {
	Do(Action) error
}

Doer does an Action against a sqlite3 database

func NewSqlite3Doer

func NewSqlite3Doer(tx *sql.Tx) Doer

func ToDoer

func ToDoer(db Doer, t db.Transaction) Doer

If t is not nil, converts t to a Doer. Otherwise returns db as the Doer.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL