go-xorm / tidb Goto Github PK
View Code? Open in Web Editor NEWXorm dialect for github.com/pingcap/tidb
License: BSD 3-Clause "New" or "Revised" License
Xorm dialect for github.com/pingcap/tidb
License: BSD 3-Clause "New" or "Revised" License
engine.Insert can not autocommit
//test case:
package main
import (
_ "github.com/pingcap/tidb"
_ "github.com/go-xorm/tidb"
"github.com/go-xorm/xorm"
"fmt"
)
type A struct {
Id int
Name string
Pv int64 `xorm:"default 1"`
}
type B struct {
Id int
Name string
Pv int `xorm:"default 1"`
}
func main() {
engine, err := xorm.NewEngine("tidb", "goleveldb://test/tidb")
if err != nil {
panic(err)
}
//create table
engine.Sync2(new(A))
engine.Sync2(new(B))
//query data
fmt.Println("-------begin query------")
//should be 0 if the first run---but every time you run the code, it still 1(it only autocommit when db created)
fmt.Println(engine.Count(new(A)))
fmt.Println(engine.Count(new(B)))
//adding data
fmt.Println("-------adding data------")
a := &A{Name:"ElvizLai"}
b := &B{Name:"ElvizLai"}
engine.Insert(a)
engine.Insert(b)
return
sess := engine.NewSession()
sess.Begin()
sess.InsertOne(a)
sess.InsertOne(b)
fmt.Println(sess.Commit())
}
出错的代码行是这样:
···
return xorm.NewEngine("tidb", "goleveldb://./data/tidb/tidb")
···
# github.com/go-xorm/tidb
../github.com/go-xorm/tidb/tidb_dialect.go:140: db.Logger undefined (type *tidb has no field or method Logger)
../github.com/go-xorm/tidb/tidb_dialect.go:141: db.Logger undefined (type *tidb has no field or method Logger)
../github.com/go-xorm/tidb/tidb_dialect.go:252: db.Logger undefined (type *tidb has no field or method Logger)
../github.com/go-xorm/tidb/tidb_dialect.go:253: db.Logger undefined (type *tidb has no field or method Logger)
../github.com/go-xorm/tidb/tidb_dialect.go:282: db.Logger undefined (type *tidb has no field or method Logger)
../github.com/go-xorm/tidb/tidb_dialect.go:283: db.Logger undefined (type *tidb has no field or method Logger)
Not able to compile with error:
go-xorm/tidb/tidb_dialect.go:151: cannot use make(map[string]bool) (type map[string]bool) as type map[string]int in assignment
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.