Documentation ¶
Overview ¶
Example ¶
package main import ( "fmt" _ "github.com/go-sql-driver/mysql" ) var defaultMySQLDSNConfig = &Config{ User: "root", Host: "localhost", Port: 3306, DB: "test", Options: "charset=utf8mb4&collation=utf8mb4_bin", } var defaultTiDBDSNConfig = &Config{ User: "root", Host: "127.0.0.1", Port: 4000, DB: "test", Options: "charset=utf8mb4&collation=utf8mb4_bin", } func main() { exec := NewExecutor(defaultMySQLDSNConfig, defaultTiDBDSNConfig) if err := exec.Open(DefaultRetryCnt); err != nil { fmt.Printf("open failed err %v", err) return } sqls := []string{"drop table t", "create table t(a int)", "show create table t", "drop table t"} if err := exec.DoDiff(sqls, nil); err != nil { fmt.Printf("do diff failed \n%v", err) } }
Output:
Index ¶
Examples ¶
Constants ¶
View Source
const DefaultRetryCnt = 1
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Executor ¶
type Executor struct { MySQLConfig *Config TiDBConfig *Config // contains filtered or unexported fields }
func NewExecutor ¶
func (*Executor) DoDiff ¶
DoDiff executes sqls in the driver configured in exec. If there is an inconsistent sql execution result, it will directly return an error, and the error message contains inconsistencies. If the execution results are the same, no error is returned. handleResultsFn is used to do special processing on the results after executing each statement.
func (*Executor) Query ¶
func (e *Executor) Query(query string) (*QueryResult, *QueryResult, error)
type QueryResult ¶
type QueryResult struct { Result *sql.Rows Error error Rendered string // contains filtered or unexported fields }
func (*QueryResult) Close ¶
func (result *QueryResult) Close()
func (*QueryResult) Content ¶
func (result *QueryResult) Content() string
func (*QueryResult) Stat ¶
func (result *QueryResult) Stat() string
Click to show internal directories.
Click to hide internal directories.