dbutil

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2023 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bench

func Bench(db *chai.DB, query string, opt BenchOptions) error

Bench takes a database and dumps its content as SQL queries in the given writer. If tables is provided, only selected tables will be outputted.

func CanReadFromStandardInput

func CanReadFromStandardInput() bool

CanReadFromStandardInput returns whether there is data to be read in stdin.

func Dump

func Dump(db *chai.DB, w io.Writer, tables ...string) error

Dump takes a database and dumps its content as SQL queries in the given writer. If tables is provided, only selected tables will be outputted.

func DumpPebble

func DumpPebble(c context.Context, db *pebble.DB, opt DumpPebbleOptions) error

func DumpSchema

func DumpSchema(db *chai.DB, w io.Writer, tables ...string) error

DumpSchema takes a database and dumps its schema as SQL queries in the given writer. If tables are provided, only selected tables will be outputted.

func ExecSQL

func ExecSQL(ctx context.Context, db *chai.DB, r io.Reader, w io.Writer) error

ExecSQL reads SQL queries from reader and executes them until the reader is exhausted. If the query has results, they will be outputted to w.

func InsertJSON

func InsertJSON(db *chai.DB, table string, r io.Reader) error

InsertJSON reads json objects from r and inserts them into the selected table. The reader can be either a stream of json objects or an array of objects.

func ListIndexes

func ListIndexes(db *chai.DB, tableName string) ([]string, error)

func OpenDB

func OpenDB(ctx context.Context, dbPath string) (*chai.DB, error)

OpenDB is a helper function that takes raw unvalidated parameters and opens a database.

func QueryTables

func QueryTables(tx *chai.Tx, tables []string, fn func(name, query string) error) error

func Restore

func Restore(ctx context.Context, db *chai.DB, dumpFile, dbPath string) error

Restore a database from a file created by chai dump. This function can be provided with an existing database (chai cli use case), otherwise new database is being created.

Types

type BenchOptions

type BenchOptions struct {
	Init       string
	N          int
	SampleSize int
	SameTx     bool
	Prepare    bool
	CSV        bool
}

type DumpPebbleOptions

type DumpPebbleOptions struct {
	KeysOnly bool
}

Jump to

Keyboard shortcuts

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