pkg

package
v0.0.0-...-5ca05ed Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2023 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const ConnStr string = "user=%s password=%s host=%s port=%d database=%s sslmode=disable "

Variables

This section is empty.

Functions

func Export2Csv

func Export2Csv(conn *pgx.Conn, conf *Config) error

func ImportCsv2DB

func ImportCsv2DB(conn *pgx.Conn, conf *Config) error

func NewDB

func NewDB(conf *Config) (*pgx.Conn, error)

Types

type Action

type Action string
const (
	ActionImport Action = "import"
	ActionExport Action = "export"
)

type Config

type Config struct {
	DBHost      string           `json:"dbHost"`
	DBName      string           `json:"dbName"`
	DBUser      string           `json:"dbUser"`
	DBPassword  string           `json:"dbPassword"`
	DBPort      int              `json:"dbPort"`
	Action      Action           `json:"action"`
	ExportTable *ExportTable     `json:"exportTable"`
	ImportTable *ImportTableConf `json:"importTable"`
}

func LoadConfig

func LoadConfig(filepath string) (*Config, error)

func (*Config) ImportAction

func (c *Config) ImportAction() bool

func (*Config) Valid

func (c *Config) Valid() error

type ExportTable

type ExportTable struct {
	ExportPath string   `json:"exportPath"`
	Tables     []string `json:"tables"`
}

type IgnoreColumn

type IgnoreColumn struct {
	Header string `json:"header"`
	Value  any    `json:"value"`
}

type ImportTable

type ImportTable struct {
	TableName     string         `json:"tableName"`
	FileName      string         `json:"fileName"`
	IgnoreColumns []IgnoreColumn `json:"ignoreColumns"`
	Header        []string
	TargetFds     []pgconn.FieldDescription
}

func (*ImportTable) String

func (t *ImportTable) String() string

type ImportTableConf

type ImportTableConf struct {
	ImportPath   string         `json:"importPath"`
	ImportTables []*ImportTable `json:"tables"`
}

Jump to

Keyboard shortcuts

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