sqlite

package
v1.32.0-rc2 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitDb

func InitDb(
	ctx context.Context,
	name string,
	db *sql.DB,
	ddls []string,
	versionMigrations []MigrationFunc,
) error

InitDb initializes the database by checking whether it needs to be created or upgraded. The ddls are the DDL statements to create the tables in the database and their initial required content. The schemaVersion will be set inside the databse if it is newly created. Otherwise, the version is read from the databse and returned. This value should be checked against the expected version to determine if the database needs to be upgraded. It is up to the caller to close the database if an error is returned by this function.

func Open

func Open(path string) (*sql.DB, error)

Open opens a database at the given path. If the database does not exist, it will be created.

Types

type MigrationFunc

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

Jump to

Keyboard shortcuts

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