mysql

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

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                  string
	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) 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) IsAutoIncrement

func (m *Column) IsAutoIncrement() 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) 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
	Cardinality  JsonNullInt64
	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) ResetCardinality

func (m *Indices) ResetCardinality()

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 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
	TableRows      int
	AvgRowLength   int
	DataLength     int
	MaxDataLength  int
	IndexLength    int
	DataFree       int
	AutoIncrement  JsonNullInt64
	TableCollation string
	CheckSum       JsonNullString
	CreateOptions  string
	TableComment   string
	Columns        Columns
	Indices        Indices
}

func (*Table) GetCharset

func (m *Table) GetCharset() string

func (*Table) GetFormatedTableName

func (m *Table) GetFormatedTableName() string

func (*Table) ToAlterSQL

func (m *Table) ToAlterSQL(sqls []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