sqliteutil

package
v1.115.6 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2024 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrMigrateTables is error class for MigrateTables.
	ErrMigrateTables = errs.Class("migrate tables")

	// ErrKeepTables is error class for MigrateTables.
	ErrKeepTables = errs.Class("keep tables")
)

Functions

func IsConstraintError

func IsConstraintError(err error) bool

IsConstraintError checks if given error is about constraint violation.

func KeepTables

func KeepTables(ctx context.Context, db tagsql.DB, tablesToKeep ...string) (err error)

KeepTables drops all the tables except the specified tables to keep.

func LoadSchemaFromSQL

func LoadSchemaFromSQL(ctx context.Context, script []string) (_ *dbschema.Schema, err error)

LoadSchemaFromSQL inserts script into connstr and loads schema.

func LoadSnapshotFromSQL

func LoadSnapshotFromSQL(ctx context.Context, script string) (_ *dbschema.Snapshot, err error)

LoadSnapshotFromSQL inserts script into connstr and loads schema.

func MigrateTablesToDatabase

func MigrateTablesToDatabase(ctx context.Context, srcDB, destDB tagsql.DB, tablesToKeep ...string) error

MigrateTablesToDatabase copies the specified tables from srcDB into destDB. All tables in destDB will be dropped other than those specified in tablesToKeep.

func QueryData

func QueryData(ctx context.Context, db dbschema.Queryer, schema *dbschema.Schema) (*dbschema.Data, error)

QueryData loads all data from tables.

func QuerySchema

func QuerySchema(ctx context.Context, db dbschema.Queryer) (*dbschema.Schema, error)

QuerySchema loads the schema from sqlite database.

func QuerySnapshot

func QuerySnapshot(ctx context.Context, db dbschema.Queryer) (*dbschema.Snapshot, error)

QuerySnapshot loads snapshot from database.

func WithTx added in v1.114.2

func WithTx(ctx context.Context, db tagsql.DB, cb func(ctx context.Context, tx tagsql.Tx) error) error

WithTx is a helper method which executes callback in transaction scope.

Types

This section is empty.

Jump to

Keyboard shortcuts

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