formats

package
v0.0.0-...-78d4bc6 Latest Latest
Warning

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

Go to latest
Published: Nov 28, 2018 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Implements INSERTS output for exported rows e.g. INSERT INTO <table> (name, last_name, something);

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Export

func Export(query string, connStr string, format DataFormat) error

Types

type CsvFormat

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

func NewCsvFormat

func NewCsvFormat(w io.Writer, delimiter rune, headerRow bool) *CsvFormat

func (*CsvFormat) Flush

func (f *CsvFormat) Flush() error

func (*CsvFormat) WriteHeader

func (f *CsvFormat) WriteHeader(columns []string) error

func (*CsvFormat) WriteRow

func (f *CsvFormat) WriteRow(values map[string]interface{}) error

type DataFormat

type DataFormat interface {
	WriteHeader(columns []string) error
	WriteRow(map[string]interface{}) error
	Flush() error
}

Supports storing data in different formats

type InsertsFormat

type InsertsFormat struct {
	DataFormat
	// contains filtered or unexported fields
}

func NewInsertsFormat

func NewInsertsFormat(w io.Writer, fileName string, tableName string) (*InsertsFormat, error)

func (*InsertsFormat) Flush

func (f *InsertsFormat) Flush() error

func (*InsertsFormat) WriteHeader

func (f *InsertsFormat) WriteHeader(columns []string) error

func (*InsertsFormat) WriteRow

func (f *InsertsFormat) WriteRow(values map[string]interface{}) error

type JSONArrayFormat

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

func NewJSONArrayFormat

func NewJSONArrayFormat(w io.Writer) *JSONArrayFormat

func (*JSONArrayFormat) Flush

func (e *JSONArrayFormat) Flush() error

func (*JSONArrayFormat) WriteHeader

func (e *JSONArrayFormat) WriteHeader(columns []string) error

Writing header for JSON is a NOP

func (*JSONArrayFormat) WriteRow

func (e *JSONArrayFormat) WriteRow(rows map[string]interface{}) error

type JSONLinesFormat

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

func NewJSONLinesFormat

func NewJSONLinesFormat(w io.Writer) *JSONLinesFormat

func (*JSONLinesFormat) Flush

func (e *JSONLinesFormat) Flush() error

func (*JSONLinesFormat) WriteHeader

func (e *JSONLinesFormat) WriteHeader(columns []string) error

Writing header for JSON is a NOP

func (*JSONLinesFormat) WriteRow

func (e *JSONLinesFormat) WriteRow(rows map[string]interface{}) error

type TemplateFormat

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

func NewTemplateFormat

func NewTemplateFormat(w io.Writer, rawTemplate string) *TemplateFormat

func (*TemplateFormat) Flush

func (e *TemplateFormat) Flush() error

func (*TemplateFormat) WriteHeader

func (e *TemplateFormat) WriteHeader(columns []string) error

func (*TemplateFormat) WriteRow

func (e *TemplateFormat) WriteRow(values map[string]interface{}) error

type XMLFormat

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

func NewXMLFormat

func NewXMLFormat(w io.Writer) *XMLFormat

func (*XMLFormat) Flush

func (e *XMLFormat) Flush() error

func (*XMLFormat) WriteHeader

func (e *XMLFormat) WriteHeader(columns []string) error

Writing header for XML is a NOP

func (*XMLFormat) WriteRow

func (e *XMLFormat) WriteRow(values map[string]interface{}) error

type XlsxFormat

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

func NewXlsxFormat

func NewXlsxFormat(fileName string, sheetName string) (*XlsxFormat, error)

func (*XlsxFormat) Flush

func (f *XlsxFormat) Flush() error

func (*XlsxFormat) WriteHeader

func (f *XlsxFormat) WriteHeader(columns []string) error

func (*XlsxFormat) WriteRow

func (f *XlsxFormat) WriteRow(values map[string]interface{}) error

Jump to

Keyboard shortcuts

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