2016-11-08 08:04:20 +00:00
|
|
|
package test
|
|
|
|
|
|
|
|
import (
|
|
|
|
"loafle.com/commons/orm/orm"
|
|
|
|
_ "loafle.com/commons/orm/orm/dialects/h2"
|
|
|
|
"log"
|
|
|
|
"testing"
|
|
|
|
)
|
|
|
|
|
|
|
|
type Animal struct {
|
|
|
|
ID int64 `sql:"AUTO_INCREMENT" gorm:"primary_key"`
|
|
|
|
Types string
|
|
|
|
Name string
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestH2Insert(t *testing.T) {
|
|
|
|
|
|
|
|
db, err := orm.Open("h2", "host=192.168.1.215 port=5435 user=sa dbname=ttt sslmode=disable password=qwe123")
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
log.Println(err)
|
|
|
|
return
|
|
|
|
}
|
|
|
|
|
|
|
|
defer db.Close()
|
|
|
|
|
|
|
|
db.LogMode(true)
|
|
|
|
|
|
|
|
db.CreateTable(&Animal{})
|
|
|
|
|
2016-11-09 02:27:59 +00:00
|
|
|
ani := Animal{Types: "ELE", Name: "CATIA"}
|
2016-11-08 08:04:20 +00:00
|
|
|
|
|
|
|
db.Create(&ani)
|
|
|
|
|
|
|
|
}
|