database

package
v1.3.0 Latest Latest
Warning

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

Go to latest
Published: May 4, 2026 License: MIT Imports: 20 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CompressionAuto = "auto"
	CompressionNone = "none"
	CompressionGzip = "gzip"
	CompressionZstd = "zstd"
)

Compression formats supported by dbdump.

Variables

This section is empty.

Functions

func CheckMySQLDump

func CheckMySQLDump() error

CheckMySQLDump verifies that mysqldump is available

func CompressionExtension added in v1.3.0

func CompressionExtension(format string) string

func ResolveCompressionFormat added in v1.3.0

func ResolveCompressionFormat(outputPath, requested string) (string, error)

func StartSSHTunnel added in v1.3.0

func StartSSHTunnel(ctx context.Context, conn *Connection) (func() error, error)

StartSSHTunnel starts an SSH local-forward tunnel and mutates the connection to use the forwarded localhost endpoint.

Types

type Connection

type Connection struct {
	Host     string
	Port     int
	User     string
	Password string
	Database string
	SSH      SSHConfig
}

Connection represents a database connection configuration

func (*Connection) Connect

func (c *Connection) Connect() (*sql.DB, error)

Connect establishes a connection to the database

func (*Connection) DSN

func (c *Connection) DSN() string

DSN returns the data source name for MySQL connection Uses mysql.Config for proper escaping and timeout configuration

func (*Connection) TestConnection

func (c *Connection) TestConnection() error

TestConnection tests if the connection is valid

type DumpOptions

type DumpOptions struct {
	Connection    *Connection
	ExcludeTables []string
	OutputFile    string
	DryRun        bool
	Compression   string
}

DumpOptions contains options for dumping the database

type DumpResult

type DumpResult struct {
	OutputFile      string
	Duration        time.Duration
	ExcludedTables  []string
	FileSize        int64
	FileSizeDisplay string
}

DumpResult contains the result of a dump operation

type Dumper

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

Dumper handles database dumping operations

func NewDumper

func NewDumper(options *DumpOptions) *Dumper

NewDumper creates a new Dumper

func (*Dumper) Dump

func (d *Dumper) Dump() (result *DumpResult, err error)

Dump performs the database dump

type Inspector

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

Inspector handles database inspection operations

func NewInspector

func NewInspector(db *sql.DB) *Inspector

NewInspector creates a new Inspector

func (*Inspector) GetAllTablesInfo

func (i *Inspector) GetAllTablesInfo() ([]TableInfo, error)

GetAllTablesInfo retrieves information for all tables

func (*Inspector) GetTableInfo

func (i *Inspector) GetTableInfo(tableName string) (*TableInfo, error)

GetTableInfo retrieves detailed information about a table

func (*Inspector) ListTables

func (i *Inspector) ListTables() ([]string, error)

ListTables returns a list of all tables in the database

type SSHConfig added in v1.3.0

type SSHConfig struct {
	Host      string
	Port      int
	User      string
	KeyFile   string
	LocalPort int
}

SSHConfig describes an optional SSH tunnel used to reach the database.

func (SSHConfig) Enabled added in v1.3.0

func (c SSHConfig) Enabled() bool

Enabled reports whether SSH tunneling should be used.

type TableInfo

type TableInfo struct {
	Name        string
	RowCount    int64
	DataSize    int64
	IndexSize   int64
	TotalSize   int64
	SizeDisplay string
}

TableInfo represents information about a table

Jump to

Keyboard shortcuts

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