io

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CountCSVDataRows

func CountCSVDataRows(path string, hasHeader bool) int

CountCSVDataRows best-effort counts data rows in a CSV file, optionally excluding the header row.

func DumpDatabase

func DumpDatabase(dbURL, dumpPath string) error

func DumpDatabaseWithConnection

func DumpDatabaseWithConnection(profile config.Profile, dumpPath string) error

DumpDatabaseWithConnection performs a database dump using a DBConnection (supports SSH tunnels)

func DumpDatabaseWithConnectionAndOptions

func DumpDatabaseWithConnectionAndOptions(profile config.Profile, dumpPath string, options *DumpOptions) error

DumpDatabaseWithConnectionAndOptions performs a database dump with advanced options using DBConnection

func DumpDatabaseWithOptions

func DumpDatabaseWithOptions(dbURL, dumpPath string, options *DumpOptions) error

DumpDatabaseWithOptions performs a database dump with advanced options

func ExportCSV

func ExportCSV(db *sql.DB, table, exportPath string) error

ExportCSV streams a PostgreSQL table to a CSV file with a live progress bar.

func ExportCSVWithOptions

func ExportCSVWithOptions(db *sql.DB, table, exportPath string, options *CSVOptions) error

ExportCSVWithOptions exports a PostgreSQL table to CSV with batch processing for better memory efficiency

func ExportCSVWithQuery

func ExportCSVWithQuery(db *sql.DB, query, exportPath string, includeHeaders bool) (int, error)

ExportCSVWithQuery runs an arbitrary SELECT and writes the results to a CSV file. It returns the number of data rows written (headers excluded).

func FormatCSVValue

func FormatCSVValue(v interface{}) string

formatCSVValue properly formats a value for CSV export

func ImportCSV

func ImportCSV(db *sql.DB, table, importPath string) error

ImportCSV imports data from a CSV file into a PostgreSQL table.

func ImportCSVWithOptions

func ImportCSVWithOptions(db *sql.DB, table, importPath string, options *CSVOptions) error

ImportCSVWithOptions imports data from a CSV file with batch processing for better performance

func MigrateDatabaseWithConnection

func MigrateDatabaseWithConnection(opts *MigrationOptions) error

MigrateDatabaseWithConnection performs database migration using DBConnection objects for SSH support

func MigrateDatabaseWithOptions

func MigrateDatabaseWithOptions(opts *MigrationOptions) error

MigrateDatabaseWithOptions performs database migration with specified options

func NewProgressBarWithTimer

func NewProgressBarWithTimer(total int64, description string) *progressbar.ProgressBar

NewProgressBarWithTimer creates a progress bar (or a spinner when the total is unknown/non-positive) and starts a goroutine that continuously appends an elapsed-time suffix to the bar's description.

func RestoreDatabase

func RestoreDatabase(dbURL, dumpPath string) error

func RestoreDatabaseSmart

func RestoreDatabaseSmart(dbURL, dumpPath string) error

RestoreDatabaseSmart automatically detects dump format and uses appropriate tool

func RestoreDatabaseSmartWithOptions

func RestoreDatabaseSmartWithOptions(dbURL, dumpPath string, options *RestoreOptions) error

RestoreDatabaseSmartWithOptions detects the dump format and restores it, honouring the supplied RestoreOptions.

func RestoreDatabaseWithConnection

func RestoreDatabaseWithConnection(profile config.Profile, dumpPath string) error

RestoreDatabaseWithConnection performs a database restore using a DBConnection (supports SSH tunnels) RestoreDatabaseWithConnection performs a database restore using a DBConnection (supports SSH tunnels)

func RestoreDatabaseWithConnectionAndOptions

func RestoreDatabaseWithConnectionAndOptions(profile config.Profile, dumpPath string, options *RestoreOptions) error

RestoreDatabaseWithConnectionAndOptions performs a database restore using a DBConnection (supports SSH tunnels), honouring the supplied RestoreOptions.

Types

type CSVOptions

type CSVOptions struct {
	BatchSize int  // Number of rows to process in each batch (default: 500)
	HasHeader bool // Whether the first row of the CSV contains column headers
}

CSVOptions contains configuration for CSV operations

func DefaultCSVOptions

func DefaultCSVOptions() *CSVOptions

DefaultCSVOptions returns default CSV configuration

type DumpOptions

type DumpOptions struct {
	Format        string   // plain, custom, directory, tar
	Compress      bool     // Enable compression
	SchemaOnly    bool     // Export schema only
	DataOnly      bool     // Export data only
	Tables        []string // Specific tables to include
	ExcludeTables []string // Tables to exclude
	Schema        string   // Specific schema
	Verbose       bool     // Verbose output
	Timeout       int      // Command timeout in seconds
}

DumpOptions contains advanced options for pg_dump

type MigrationOptions

type MigrationOptions struct {
	SourceProfile  config.Profile
	TargetProfile  config.Profile
	SchemaOnly     bool
	DataOnly       bool
	Tables         []string
	Validate       bool
	EnableRollback bool
	Verbose        bool
	Timeout        int
	Overwrite      bool
	BatchSize      int
}

MigrationOptions defines options for database migration

type RestoreOptions

type RestoreOptions struct {
	// Clean drops database objects before recreating them (pg_restore only).
	Clean bool
	// Timeout, when > 0, aborts the restore after the given number of seconds.
	Timeout int
	// Strict makes any restore error fatal. By default restore tolerates
	// non-fatal errors reported by pg_restore (e.g. minor client/server
	// version mismatches such as "unrecognized configuration parameter").
	// Note that pg_restore exits with code 1 when it encounters ignorable
	// errors, so the default (Strict == false) keeps restores resilient to
	// version skew.
	Strict bool
}

RestoreOptions controls restore behaviour for pg_restore/psql.

Jump to

Keyboard shortcuts

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