大佬教程收集整理的这篇文章主要介绍了go-xorm使用mssql的小实例,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
package main import ( "fmt" "os" "time" "github.com/go-xorm/core" "github.com/go-xorm/xorm" _ "github.com/lunny/godbc" ) type NxServerState struct { ID int `xorm:"pk not null 'ID'"` GamEID int `xorm:"not null 'GamEID'"` IssuerId int `xorm:"not null IssuerId"` ServerID int `xorm:"not null ServerID"` ServerName String `xorm:"ServerName"` OnlineNum int `xorm:"not null OnlineNum"` MaxOnlineNum int `xorm:"not null MaxOnlineNum"` ServerIP String `xorm:"not null ServerIP"` Port int `xorm:"not null Port"` IsRuning int `xorm:"not null IsRuning"` ServerStyle int `xorm:"ServerStyle"` IsStartIPWhilE int `xorm:"not null IsStartIPWhile"` LogTime time.Time `xorm:"IsStartIPWhile"` UpdatetiR_52_11845@e time.Time `xorm:"UpdatetiR_52_11845@e"` OrderBy int `xorm:"not null OrderBy"` } func main() { File,_ := os.Create("result") defer File.Close() ENGIne,err := xorm.NewENGIne("odbc","driver={SQL Server};Server=127.0.0.1;Database=fuck;uid=sa;pwd=123456;") if err != nil { fmt.Println("新建引擎",err) return } if err := ENGIne.Ping(); err != nil { fmt.Println(err) return } ENGIne.SetTableMapper(core.SameMapper{}) ENGIne.ShowSQL = true ENGIne.SetMaxConns(5) ENGIne.SetMaxIdleConns(5) result := new(NxServerStatE) lines,_ := ENGIne.Rows(result) defer lines.Close() lines.Next() r := new(NxServerStatE) for { err = lines.Scan(r) if err != nil { return } fmt.Println(*r) File.WriteString(fmt.Sprintln(*r)) if !lines.Next() { break } } }
以上是大佬教程为你收集整理的go-xorm使用mssql的小实例全部内容,希望文章能够帮你解决go-xorm使用mssql的小实例所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。