chiv

package module
v0.0.0-...-ebd7022 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2019 License: MIT Imports: 12 Imported by: 0

README

chiv

Codeship Status for gavincabbage/chiv Go Report GoDoc License

Archive relational database tables to Amazon S3.

Example

TODO

CLI

TODO

Documentation

Overview

Package chiv archives relational database tables to Amazon S3.

Index

Constants

This section is empty.

Variables

View Source
var (
	// DefaultFormat is CSV.
	DefaultFormat = CSV
	// ErrRecordLength does not match the number of columns.
	ErrRecordLength = errors.New("record length does not match number of columns")
	// ErrParserRegex initialization problem.
	ErrParserRegex = errors.New("initializing parser regex")
	// ErrBuildingQuery string.
	ErrBuildingQuery = errors.New("building query")
)

Functions

func Archive

func Archive(db *sql.DB, s3 *s3manager.Uploader, table, bucket string, options ...Option) error

Archive a database table to S3.

func ArchiveWithContext

func ArchiveWithContext(ctx context.Context, db *sql.DB, s3 *s3manager.Uploader, table, bucket string, options ...Option) error

ArchiveWithContext is like Archive, with context.

Types

type Archiver

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

Archiver archives database tables to Amazon S3.

func NewArchiver

func NewArchiver(db *sql.DB, s3 *s3manager.Uploader, options ...Option) *Archiver

NewArchiver constructs an archiver with the given database, S3 uploader and options. Options set on creation apply to all calls to Archive unless overridden.

func (*Archiver) Archive

func (a *Archiver) Archive(table, bucket string, options ...Option) error

Archive a database table to S3. Any options provided override those set on creation.

func (*Archiver) ArchiveWithContext

func (a *Archiver) ArchiveWithContext(ctx context.Context, table, bucket string, options ...Option) error

ArchiveWithContext is like Archive, with context. Any options provided override those set on creation.

type Formatter

type Formatter interface {
	Format([][]byte) error
	Close() error
}

Formatter formats and writes records.

func CSV

func CSV(w io.Writer, columns []*sql.ColumnType) (Formatter, error)

CSV returns an initialized csvFormatter.

func JSON

func JSON(w io.Writer, columns []*sql.ColumnType) (Formatter, error)

JSON returns an initialized jsonFormatter with an open JSON array.

func YAML

func YAML(w io.Writer, columns []*sql.ColumnType) (Formatter, error)

YAML returns an initialized yamlFormatter.

type FormatterFunc

type FormatterFunc func(io.Writer, []*sql.ColumnType) (Formatter, error)

FormatterFunc returns an initialized Formatter.

type Option

type Option func(*Archiver)

Option configures the Archiver. Options can be provided when creating an Archiver or on each call to Archive.

func WithColumns

func WithColumns(c ...string) Option

WithColumns configures a list of column names to archive.

func WithExtension

func WithExtension(s string) Option

WithExtension configures an extension for object keys uploaded to S3.

func WithFormat

func WithFormat(f FormatterFunc) Option

WithFormat configures the upload format.

func WithKey

func WithKey(s string) Option

WithKey configures the object key uploaded to S3.

func WithNull

func WithNull(s string) Option

WithNull configures a custom null string.

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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