dbi

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Apr 26, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseTable

func ParseTable(table string) (schemaName, tableName string)

ParseTable parses the schema and table name from table which may be like db1.t1

Types

type Batcher

type Batcher interface {
	// GetBatchNum returns the batch num
	GetBatchNum() int
	// AddRow adds a row to batcher and execute when rows accumulated to the batch num.
	AddRow(colValues []interface{}) error
	// Complete completes the left rows that less than batch num.
	Complete() (int, error)
}

Batcher ...

type InsertBatcher

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

InsertBatcher ...

func NewInsertBatch

func NewInsertBatch(table string, columnNames []string, batchNum int, db *sql.DB,
	batchOp func(int), verbose, rows int) *InsertBatcher

NewInsertBatch ...

func (*InsertBatcher) AddRow

func (b *InsertBatcher) AddRow(colValues []interface{}) error

AddRow adds a row to batcher and execute when rows accumulated to the batch num.

func (*InsertBatcher) Complete

func (b *InsertBatcher) Complete() (int, error)

Complete completes the left rows that less than batch num.

func (InsertBatcher) GetBatchNum

func (b InsertBatcher) GetBatchNum() int

GetBatchNum returns the batch num

type MySQLSchema

type MySQLSchema struct {
	DS string
	// contains filtered or unexported fields
}

MySQLSchema ...

func CreateMySQLSchema

func CreateMySQLSchema(dataSourceName string) (*MySQLSchema, error)

CreateMySQLSchema ...

func (MySQLSchema) CompatibleDs

func (m MySQLSchema) CompatibleDs() string

CompatibleDs returns the dataSourceName from various the compatible format.

func (MySQLSchema) Pump

func (m MySQLSchema) Pump(table string, rowsPumped chan<- model.RowsPumped, config model.PumpConfig,
	ready chan bool, onerr string, retryMaxTimes int) error

Pump ...

func (*MySQLSchema) SetVerbose

func (m *MySQLSchema) SetVerbose(verbose int)

SetVerbose set verbose mode

func (MySQLSchema) TableColumns

func (m MySQLSchema) TableColumns(table string) ([]model.TableColumn, error)

TableColumns ...

func (MySQLSchema) Tables

func (m MySQLSchema) Tables() ([]model.Table, error)

Tables ...

type MySQLTable

type MySQLTable struct {
	Name    string `name:"TABLE_NAME"`
	Comment string `name:"TABLE_COMMENT"`
}

MySQLTable ...

func (MySQLTable) GetComment

func (m MySQLTable) GetComment() string

GetComment ...

func (MySQLTable) GetName

func (m MySQLTable) GetName() string

GetName ...

type MyTableColumn

type MyTableColumn struct {
	Name         string `name:"COLUMN_NAME"`
	Type         string `name:"COLUMN_TYPE"`
	Extra        string `name:"EXTRA"` // auto_increment
	Comment      string `name:"COLUMN_COMMENT"`
	DataType     string `name:"DATA_TYPE"`
	MaxLength    int    `name:"CHARACTER_MAXIMUM_LENGTH"`
	Nullable     string `name:"IS_NULLABLE"`
	Default      string `name:"COLUMN_DEFAULT"`
	CharacterSet string `name:"CHARACTER_SET_NAME"`

	NumericPrecision int `name:"NUMERIC_PRECISION"`
	NumericScale     int `name:"NUMERIC_SCALE"`
	// contains filtered or unexported fields
}

MyTableColumn ...

func (MyTableColumn) GetCharacterSet

func (c MyTableColumn) GetCharacterSet() string

GetCharacterSet returns the CharacterSet of the column

func (MyTableColumn) GetComment

func (c MyTableColumn) GetComment() string

GetComment ...

func (MyTableColumn) GetDataType

func (c MyTableColumn) GetDataType() string

GetDataType ...

func (MyTableColumn) GetMaxSize

func (c MyTableColumn) GetMaxSize() int

GetMaxSize ...

func (MyTableColumn) GetName

func (c MyTableColumn) GetName() string

GetName ...

func (MyTableColumn) GetRandomizer

func (c MyTableColumn) GetRandomizer() model.Randomizer

GetRandomizer ...

func (MyTableColumn) IsAutoIncrement

func (c MyTableColumn) IsAutoIncrement() bool

IsAutoIncrement tells if the col is auto_increment or not. eg. create table a.ta(id int auto_increment, name varchar(10), age int, primary key(id));

func (MyTableColumn) IsNullable

func (c MyTableColumn) IsNullable() bool

IsNullable ...

Jump to

Keyboard shortcuts

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