database

package
v0.11.1-0...-8ab92b3 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	MySQLImportCommand    = "mysql"
	PostgresImportCommand = "psql"
)
View Source
var ErrUnknownDatabaseEngine = fmt.Errorf("unknown database engine detected from file")

ErrUnknownDatabaseEngine is returned when we are unable to determine the engine type from a database backup file.

Functions

func DefaultImportToolFinder

func DefaultImportToolFinder(engine, version string) (string, error)

DefaultImportToolFinder is a tool that is used to find the executable path to the import tool such as mysql or psql. It is a func that is provided to the Importer.Import func. It will return the path to the executable or an error if the command is not found

func DetermineEngine

func DetermineEngine(file string) (string, error)

DetermineEngine takes a file and will check if the content of the file is for mysql or postgres db imports. It will return the engine "mysql" or "postgres" if it can determine the engine. If it cannot, it will return an error.

func HasCreateStatement

func HasCreateStatement(file string) (bool, error)

HasCreateStatement takes a file and will determine if the file will create a database during import. If it creates a database, it will return true otherwise it will return false.

func NewImporter

func NewImporter() *importer

NewImporter takes options and returns a new database importer.

func PrepareArchiveFromPath

func PrepareArchiveFromPath(path string) (io.Reader, string, error)

PrepareArchiveFromPath takes a path to a file, which is presumed to be a database backup and will determine if the file is already a format the Docker API can use. If the file is a zip or tar file, it will open the sql file in the archive and write the contents to a temporary file and then use the docker archive.Generate functionality to prepare for copying the file to the API.

func Validate

func Validate(opts *ImportOptions) error

Validate takes import options and returns an error if the options are missing details we need to run the import.

Types

type ImportOptions

type ImportOptions struct {
	Compressed      bool
	CompressionType string
	Engine          string
	Version         string
	Hostname        string
	Port            string
	DatabaseName    string
	File            string
}

ImportOptions are used to create a new importer. It contains all of the information needed to run an import.

type Importer

type Importer interface {
	Import(opts *ImportOptions, finder func(engine, version string) (string, error)) error
}

Importer is an interface that is designed to import a database backup into a database server.

Jump to

Keyboard shortcuts

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