tableinfo

package
v0.0.0-...-1609ee8 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2018 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ColumnInfo

type ColumnInfo struct {
	Index         int
	Name          string
	Type          string
	IsPrimary     bool
	Nullable      bool
	Default       string
	HasDefault    bool
	Unsigned      bool
	AutoIncrement bool
}

ColumnInfo hold column base info

func FindColumnByName

func FindColumnByName(cols []*ColumnInfo, cname string) *ColumnInfo

FindColumnByName returns the column matches column name

type ColumnWithValue

type ColumnWithValue struct {
	Column *ColumnInfo
	Value  interface{}
}

ColumnWithValue holds column value

func FillColumnsWithValue

func FillColumnsWithValue(ti *TableInfo, values []interface{}) []*ColumnWithValue

FillColumnsWithValue fills columns value with binlog value final columns count is determined by binlog columns, so make sure binlog columns count is not greater than table info columns (panic)

func (*ColumnWithValue) ValueToString

func (c *ColumnWithValue) ValueToString() string

ValueToString converts value to string type

type TableInfo

type TableInfo struct {
	Schema       string
	Name         string
	Columns      []*ColumnInfo
	IndexColumns []*ColumnInfo
	// Check table info changed
	BinlogColumns int
}

TableInfo hold column info

func GetTableInfo

func GetTableInfo(db *sql.DB, schema string, table string) (*TableInfo, error)

GetTableInfo get table info from database

func (*TableInfo) GetTableColumnInfo

func (ti *TableInfo) GetTableColumnInfo(db *sql.DB, schema string, table string) error

GetTableColumnInfo get columns info from database

func (*TableInfo) GetTablePrimaryKeys

func (ti *TableInfo) GetTablePrimaryKeys(db *sql.DB, schema string, table string) error

GetTablePrimaryKeys get all primary keys

Jump to

Keyboard shortcuts

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