本文整理匯總了Golang中github.com/siddontang/go-mysql/mysql.Executer類的典型用法代碼示例。如果您正苦於以下問題:Golang Executer類的具體用法?Golang Executer怎麽用?Golang Executer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了Executer類的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: fetchIndexes
func (ta *Table) fetchIndexes(conn mysql.Executer) error {
r, err := conn.Execute(fmt.Sprintf("show index from %s.%s", ta.Schema, ta.Name))
if err != nil {
return err
}
var currentIndex *Index
currentName := ""
for i := 0; i < r.RowNumber(); i++ {
indexName, _ := r.GetString(i, 2)
if currentName != indexName {
currentIndex = ta.AddIndex(indexName)
currentName = indexName
}
cardinality, _ := r.GetUint(i, 6)
colName, _ := r.GetString(i, 4)
currentIndex.AddColumn(colName, cardinality)
}
if len(ta.Indexes) == 0 {
return nil
}
pkIndex := ta.Indexes[0]
if pkIndex.Name != "PRIMARY" {
return nil
}
ta.PKColumns = make([]int, len(pkIndex.Columns))
for i, pkCol := range pkIndex.Columns {
ta.PKColumns[i] = ta.FindColumn(pkCol)
}
return nil
}
示例2: fetchColumns
func (ta *Table) fetchColumns(conn mysql.Executer) error {
r, err := conn.Execute(fmt.Sprintf("describe %s.%s", ta.Schema, ta.Name))
if err != nil {
return err
}
for i := 0; i < r.RowNumber(); i++ {
name, _ := r.GetString(i, 0)
colType, _ := r.GetString(i, 1)
extra, _ := r.GetString(i, 5)
ta.AddColumn(name, colType, extra)
}
return nil
}