db

package
v0.0.0-...-986b357 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package db deals with database access.

Index

Constants

View Source
const (
	// Pragmas are used to initialize an in-memory database. Useful for tests.
	Pragmas = `?cache=shared&mode=memory`

	// For the time being, use an in-memory database.
	DefaultFilename = `file:test.db` + Pragmas

	// SqliteDriver is the name of the used SQL driver module.
	SqliteDriver = `sqlite3`
)

Variables

View Source
var (
	// NowFn is a function that retrieves the current time.  Can be overridden
	// in tests.
	NowFn = time.Now
)

Functions

func AddSignal

func AddSignal(ctx context.Context, tx *sql.Tx,
	name string, kindCode vcd.VarKindCode, code string, size int) error

func AddValue

func AddValue(ctx context.Context, tx *sql.Tx,
	timestamp uint64, code string, value string) error

func CreateDBFile

func CreateDBFile(name string) (bool, error)

CreateDBFile creates the database file if it does not already exist. Returns true, if the db schema needs to be created.

func CreateSchema

func CreateSchema(ctx context.Context, tx *sql.Tx) error

CreateSchema schedules a transactional schema creation.

func FindSignalByName

func FindSignalByName(ctx context.Context, tx *sql.Tx, name string) *sql.Row

func FindValueById

func FindValueById(ctx context.Context, tx *sql.Tx, id uint64) *sql.Row

func OpenDB

func OpenDB(ctx context.Context, name string) (*sql.DB, error)

OpenDB opens the database by name, creating with the correct schema if one does not exist.

func Scan1

func Scan1[T any](rows *sql.Rows) (*T, error)

func Scan2

func Scan2[T any, U any](rows *sql.Rows) (*T, *U, error)

func Scan3NoNext

func Scan3NoNext[T any, U any, V any](rows *sql.Rows) (*T, *U, *V, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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