mysql

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2018 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	PartitionMethodLinearKey  = "LINEAR KEY"
	PartitionMethodLinearHash = "LINEAR HASH"
	PartitionMethodRange      = "RANGE COLUMNS"
)

Variables

View Source
var (
	TimeFmt string = "2006-01-02 15:04:05"
)

Functions

func ForeignKeyCheck added in v0.5.4

func ForeignKeyCheck(turnOn bool) string

ForeignKeyCheck returns `"SET FOREIGN_KEY_CHECKS = %s"`

func Quote

func Quote(name string) string

func QuoteMulti

func QuoteMulti(names []string) []string

func QuoteString

func QuoteString(name string) string

Types

type Chunk

type Chunk struct {
	TableName   string
	ColumnNames []string
	Seeds       Seeds
}

func GetChunk

func GetChunk(db *sql.DB, table string, colName *string) (*Chunk, error)

func (*Chunk) GetColumnIndexBy

func (m *Chunk) GetColumnIndexBy(columnName string) (int, error)

func (*Chunk) GetFormatedTableName

func (m *Chunk) GetFormatedTableName() string

func (*Chunk) GetSeedGroupBy

func (m *Chunk) GetSeedGroupBy(columnName string) (map[interface{}]Seed, error)

func (*Chunk) ToDeleteSQL

func (m *Chunk) ToDeleteSQL(colIdx int) []string

func (*Chunk) ToInsertSQL

func (m *Chunk) ToInsertSQL() []string

func (*Chunk) ToReplaceSQL

func (m *Chunk) ToReplaceSQL() []string

func (*Chunk) ToTrancateSQL

func (m *Chunk) ToTrancateSQL() string

type Column

type Column struct {
	TableCatalog           string
	TableSchema            string
	TableName              string
	ColumnName             string
	OrdinalPosition        int32
	ColumnDefault          JsonNullString
	Nullable               string
	DataType               string
	CharacterMaximumLength JsonNullInt64
	CharacterOctetLength   JsonNullInt64
	NumericPrecision       JsonNullInt64
	NumericScale           JsonNullInt64
	CharacterSetName       JsonNullString
	CollationName          JsonNullString
	ColumnType             string
	ColumnKey              string
	Extra                  JsonNullString
	Privileges             string
	ColumnComment          string
}

func GetColumns

func GetColumns(db *sql.DB, schema string) ([]*Column, error)

func (*Column) AppendPos added in v0.4.2

func (m *Column) AppendPos(all Columns) string

func (*Column) CompareCharacterSet added in v0.4.1

func (m *Column) CompareCharacterSet(col *Column) bool

func (*Column) FormatDefault

func (m *Column) FormatDefault() string

func (*Column) FormatExtra added in v0.4.7

func (m *Column) FormatExtra() string

func (*Column) HasCharacterSetName added in v0.4.1

func (m *Column) HasCharacterSetName() bool

func (*Column) HasComment

func (m *Column) HasComment() bool

func (*Column) HasDefault

func (m *Column) HasDefault() bool

func (*Column) HasExtra added in v0.4.7

func (m *Column) HasExtra() bool

func (*Column) IsMul

func (m *Column) IsMul() bool

func (*Column) IsNullable

func (m *Column) IsNullable() bool

func (*Column) IsPrimary

func (m *Column) IsPrimary() bool

func (*Column) IsUnique

func (m *Column) IsUnique() bool

func (*Column) ToAddSQL

func (m *Column) ToAddSQL(pos string) string

func (*Column) ToDropSQL

func (m *Column) ToDropSQL() string

func (*Column) ToModifyCharsetSQL added in v0.4.1

func (m *Column) ToModifyCharsetSQL() string

func (*Column) ToModifySQL

func (m *Column) ToModifySQL() string

func (*Column) ToSQL

func (m *Column) ToSQL() string

type Columns

type Columns []*Column

func (Columns) Contains

func (m Columns) Contains(c *Column) bool

func (Columns) GetBeforeColumn added in v0.5.0

func (m Columns) GetBeforeColumn(col *Column) *Column

func (Columns) GetSortedColumnNames

func (m Columns) GetSortedColumnNames() []string

func (Columns) GroupByColumnName

func (m Columns) GroupByColumnName() map[string]*Column

func (Columns) ToAddSQL

func (m Columns) ToAddSQL(all Columns) []string

func (Columns) ToDropSQL

func (m Columns) ToDropSQL() []string

func (Columns) ToSQL

func (m Columns) ToSQL() []string

type Index

type Index []IndexColumn

func (Index) ColumnNames

func (m Index) ColumnNames() []string

func (Index) GetKeyName

func (m Index) GetKeyName() string

func (Index) IsPrimaryKey

func (m Index) IsPrimaryKey() bool

func (Index) IsUniqueKey

func (m Index) IsUniqueKey() bool

func (Index) KeyNamesWithSubPart

func (m Index) KeyNamesWithSubPart() []string

type IndexColumn

type IndexColumn struct {
	Table        string
	NonUniue     int8
	KeyName      string
	SeqInIndex   int32
	ColumnName   string
	Collation    string
	SubPart      JsonNullString
	Packed       JsonNullString
	Null         string
	IndexType    string
	Comment      string
	IndexComment string
}

type Indices

type Indices []Index

func GetIndices

func GetIndices(db *sql.DB, table string) (Indices, error)

func (Indices) GetSortedKeys

func (m Indices) GetSortedKeys() []string

func (Indices) GroupByKeyName

func (m Indices) GroupByKeyName() map[string]Indices

func (Indices) ToAddSQL

func (m Indices) ToAddSQL() []string

func (Indices) ToDropSQL

func (m Indices) ToDropSQL() []string

func (Indices) ToSQL

func (m Indices) ToSQL() []string

type JsonNullInt64

type JsonNullInt64 struct {
	sql.NullInt64
}

func (JsonNullInt64) MarshalJSON

func (v JsonNullInt64) MarshalJSON() ([]byte, error)

func (*JsonNullInt64) UnmarshalJSON

func (v *JsonNullInt64) UnmarshalJSON(data []byte) error

type JsonNullString

type JsonNullString struct {
	sql.NullString
}

func (JsonNullString) MarshalJSON

func (v JsonNullString) MarshalJSON() ([]byte, error)

func (*JsonNullString) UnmarshalJSON

func (v *JsonNullString) UnmarshalJSON(data []byte) error

type Partition added in v0.4.3

type Partition struct {
	TableCatalog                string
	TableSchema                 string
	TableName                   string
	PartitionName               string
	SubpartitionName            JsonNullString
	PartitionOrdinalPosition    string
	SubpartitionOrdinalPosition JsonNullString
	PartitionMethod             string
	SubpartitionMethod          JsonNullString
	PartitionExpression         string
	SubpartitionExpression      JsonNullString
	PartitionDescription        JsonNullString
	PartitionComment            string
	Nodegroup                   string
	TablespaceName              JsonNullString
}

type Partitions added in v0.4.3

type Partitions []*Partition

func GetPartitions added in v0.4.3

func GetPartitions(db *sql.DB, schema string, tableName string) (Partitions, error)

func (Partitions) ToSQL added in v0.4.3

func (m Partitions) ToSQL() string

type Seed

type Seed struct {
	ColumnData []interface{}
}

func (Seed) ToColumnValue

func (m Seed) ToColumnValue(colIdx int) string

func (Seed) ToValueSQL

func (m Seed) ToValueSQL() string

func (Seed) ValueEqual

func (m Seed) ValueEqual(seed Seed) bool

type Seeds

type Seeds []Seed

func (Seeds) ToColumnValues

func (m Seeds) ToColumnValues(colIdx int) []string

func (Seeds) ToValueSQL

func (m Seeds) ToValueSQL() []string

type Table

type Table struct {
	TableCatalog   string
	TableSchema    string
	TableName      string
	TableType      string
	Engine         string
	Version        int
	RowFormat      string
	TableCollation string
	CheckSum       JsonNullString
	CreateOptions  string
	TableComment   string
	Columns        Columns
	Indices        Indices
	Partitions     Partitions
}

func (*Table) GetCharset

func (m *Table) GetCharset() string

func (*Table) GetFormatedTableName

func (m *Table) GetFormatedTableName() string

func (*Table) IsPartitioned added in v0.4.3

func (m *Table) IsPartitioned() bool

func (*Table) ToAlterSQL

func (m *Table) ToAlterSQL(sqls []string, partitionSql string) string

func (*Table) ToConvertCharsetSQL added in v0.4.1

func (m *Table) ToConvertCharsetSQL() string

func (*Table) ToCreateSQL

func (m *Table) ToCreateSQL() string

func (*Table) ToDropSQL

func (m *Table) ToDropSQL() string

type Tables

type Tables []*Table

func GetTables

func GetTables(db *sql.DB, schema string, tableNames ...string) (Tables, error)

func (Tables) Contains

func (m Tables) Contains(t *Table) bool

func (Tables) GetFormatedTableNames

func (m Tables) GetFormatedTableNames() []string

func (Tables) GetSortedTableNames

func (m Tables) GetSortedTableNames() []string

func (Tables) GroupByTableName

func (m Tables) GroupByTableName() map[string]*Table

Jump to

Keyboard shortcuts

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