load

package
v0.0.0-...-e501bf0 Latest Latest
Warning

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

Go to latest
Published: Jun 12, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FileLoad

type FileLoad struct {
	Path     string
	IsSchema bool
}

FileLoad represents a single SQL file to load.

type Importer

type Importer struct {
	// contains filtered or unexported fields
}

Importer loads SQL files produced by go-dump into a MySQL server.

func New

func New(db *sql.DB, workers int, skipSchema bool) *Importer

New creates an Importer. Call Close() when done.

func (*Importer) Close

func (imp *Importer) Close() error

Close releases the underlying database connection pool.

func (*Importer) ImportDirectory

func (imp *Importer) ImportDirectory(ctx context.Context, dir, pattern string, ls *LoadState) error

ImportDirectory loads all SQL files in dir matching pattern. Schema (definition) files are loaded serially first; data files run in parallel. Pass a non-nil LoadState to enable resume (skip already-loaded files).

func (*Importer) ImportFile

func (imp *Importer) ImportFile(ctx context.Context, path string) error

ImportFile loads a single SQL file.

type LoadState

type LoadState struct {
	StartTime      time.Time `json:"start_time"`
	CompletedFiles []string  `json:"completed_files"`
	// contains filtered or unexported fields
}

LoadState persists which files have been successfully loaded, enabling --resume. Written atomically to <directory>/load-state.json after each successful file load.

func NewLoadState

func NewLoadState(dir string) (*LoadState, error)

NewLoadState reads an existing load-state.json from dir, or returns a fresh state.

func (*LoadState) HasFile

func (ls *LoadState) HasFile(name string) bool

HasFile reports whether name was already successfully loaded.

func (*LoadState) Len

func (ls *LoadState) Len() int

Len returns the number of files recorded as completed.

func (*LoadState) Mark

func (ls *LoadState) Mark(name string) error

Mark records name as complete and flushes the state file atomically.

Jump to

Keyboard shortcuts

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