dump

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 4, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrSkip = errors.New("Handler error, but skipped")
)

Functions

func Parse

func Parse(r io.Reader, h ParseHandler, parseBinlogPos bool) error

Parse the dump data with Dumper generate. It can not parse all the data formats with mysqldump outputs

Types

type Dumper

type Dumper struct {
	// mysqldump execution path, like mysqldump or /usr/bin/mysqldump, etc...
	ExecutionPath string

	Addr     string
	User     string
	Password string
	Protocol string

	// Will override Databases
	Tables  []string
	TableDB string

	Databases []string

	Where   string
	Charset string

	IgnoreTables map[string][]string

	ExtraOptions []string

	ErrOut io.Writer
	// contains filtered or unexported fields
}

Unlick mysqldump, Dumper is designed for parsing and syning data easily.

func NewDumper

func NewDumper(executionPath string, addr string, user string, password string) (*Dumper, error)

func (*Dumper) AddDatabases

func (d *Dumper) AddDatabases(dbs ...string)

func (*Dumper) AddIgnoreTables

func (d *Dumper) AddIgnoreTables(db string, tables ...string)

func (*Dumper) AddTables

func (d *Dumper) AddTables(db string, tables ...string)

func (*Dumper) Dump

func (d *Dumper) Dump(w io.Writer) error

func (*Dumper) DumpAndParse

func (d *Dumper) DumpAndParse(h ParseHandler) error

DumpAndParse: Dump MySQL and parse immediately

func (*Dumper) Reset

func (d *Dumper) Reset()

func (*Dumper) SetCharset

func (d *Dumper) SetCharset(charset string)

func (*Dumper) SetErrOut

func (d *Dumper) SetErrOut(o io.Writer)

func (*Dumper) SetExtraOptions

func (d *Dumper) SetExtraOptions(options []string)

func (*Dumper) SetHexBlob

func (d *Dumper) SetHexBlob(v bool)

func (*Dumper) SetMaxAllowedPacket

func (d *Dumper) SetMaxAllowedPacket(i int)

func (*Dumper) SetProtocol

func (d *Dumper) SetProtocol(protocol string)

func (*Dumper) SetWhere

func (d *Dumper) SetWhere(where string)

func (*Dumper) SkipMasterData

func (d *Dumper) SkipMasterData(v bool)

SkipMasterData: In some cloud MySQL, we have no privilege to use `--master-data`.

type ParseHandler

type ParseHandler interface {
	// Parse CHANGE MASTER TO MASTER_LOG_FILE=name, MASTER_LOG_POS=pos;
	BinLog(name string, pos uint64) error
	GtidSet(gtidsets string) error
	Data(schema string, table string, values []string) error
}

Jump to

Keyboard shortcuts

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