dbutil

package
v0.15.3 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bench added in v0.14.0

func Bench(db *genji.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 *genji.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 added in v0.15.3

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

func DumpSchema added in v0.12.0

func DumpSchema(db *genji.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 *genji.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 *genji.DB, table string, r io.Reader) error

InsertJSON reads json documents 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 added in v0.13.0

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

func OpenDB

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

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

func QueryTables added in v0.13.0

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

func Restore added in v0.15.3

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

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

Types

type BenchOptions added in v0.14.0

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

type DumpPebbleOptions added in v0.15.3

type DumpPebbleOptions struct {
	KeysOnly bool
}

Jump to

Keyboard shortcuts

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