etlsql

package
v0.0.6-alpha Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithBatchSize

func WithBatchSize(n int) insertOptFunc

WithBatchSize sets the number of rows to insert in a single batch. might still execute multiple inserts.

func WithDDLSync

func WithDDLSync(ddlSync DDLSync) insertOptFunc

WithDDLSync sets the DDL sync mode.

func WithInsertWorkers

func WithInsertWorkers(n int) insertOptFunc

WithInsertWorkers sets the number of workers to use for inserting rows.

func WithNullables

func WithNullables(nullables ...string) insertOptFunc

WithNullables sets the columns that can be null.

func WithTypeOverride

func WithTypeOverride(fn func(t dialect.Col) string) insertOptFunc

WithTypeOverride uses the sql type returned by the func for col if the func returns an empty string, the default type is used.

Types

type DB

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

func New

func New(d Dialect, db Q) DB

New returns a new DB iterator with the given dialect and database.

func Open

func Open(d Dialect, driver, dsn string) DB

Open opens a DB connection similar to sql.Open and returns a db Iterator.

func (DB) Err

func (d DB) Err() error

func (DB) Insert

func (d DB) Insert(it Iter, table string, opts ...insertOptFunc) error

func (DB) Q

func (d DB) Q() Q

func (DB) Query

func (d DB) Query(query string, args ...any) Iter

Query executes the given query and returns an iterator that produces drow.Row.

type DDLSync

type DDLSync int
const (
	DDLNone DDLSync = iota
	DDLCreate
	DDLAddColumns
)

type Dialect

type Dialect interface {
	TableDef(ctx context.Context, db SQLQuery, name string) (dialect.Table, error)
	CreateTable(ctx context.Context, db SQLExec, name string, table dialect.Table) error
	AddColumns(ctx context.Context, db SQLExec, name string, table dialect.Table) error
	Insert(ctx context.Context, db SQLExec, name string, rows []Row) error
}

type Iter

type Iter = etl.Iter

type Q

type Q interface {
	SQLQuery
	SQLExec
	Begin() (*sql.Tx, error)
}

type Row

type Row = drow.Row

type SQLExec

type SQLExec interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
}

type SQLQuery

type SQLQuery interface {
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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