datastorage

package
v0.0.0-...-266bd3a Latest Latest
Warning

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

Go to latest
Published: May 14, 2021 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package datastorage abstracts the data storage source.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InsertOptions

type InsertOptions struct {
	// Formatter formats each value of a record.
	// Optional.
	Formatter func(value string) string
	// IgnoreDuplicateError ignores duplicate error from the datasource if set
	// to true.
	IgnoreDuplicateError bool
}

InsertOptions gathers the options of an insert process.

type Inserter

type Inserter interface {
	Insert(ctx context.Context, records [][]string, options InsertOptions) error
}

Inserter inserts records from a CSV file to a datasource.

type MySQLInserter

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

MySQLInserter implements Inserter for a MySQL datasource.

func NewMySQLInserter

func NewMySQLInserter(dsn, table string, columns []string, timeout time.Duration) (*MySQLInserter, error)

NewMySQLInserter creates an instance of MySQLInserter.

func (*MySQLInserter) Insert

func (inserter *MySQLInserter) Insert(ctx context.Context, records [][]string, options InsertOptions) error

Insert inserts records to a MySQL table.

Jump to

Keyboard shortcuts

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