package main
import (
"database/sql"
"fmt"
_ "github.com/go-sql-driver/mysql"
)
func main() {
db, err := sql.Open("mysql", "root:@tcp(192.168.9.242:3306)/HSS?charset=utf8")
if err != nil {
fmt.Println("failed to open database:", err.Error())
return
}
defer db.Close()
rows, err := db.Query("SELECT * FROM APN_SELECTION")
if err != nil {
fmt.Println("fetech data failed:", err.Error())
return
}
defer rows.Close()
for rows.Next() {
var RID int
var IMSI int
var APN_PROFILE int
var TYPE_OF_CONTEXT int
var STATIC_PDN_ADDRESS_ALLOCATION string
var SERVED_PARTY_IPV4_PRESENCE string
var SERVED_PARTY_IPV4_ADDR string
var SERVED_PARTY_IPV6_PRESENCE string
var SERVED_PARTY_IPV6_ADDR string
//rows.Columns()
rows.Scan(&RID, &IMSI, &APN_PROFILE, &TYPE_OF_CONTEXT, &STATIC_PDN_ADDRESS_ALLOCATION, &SERVED_PARTY_IPV4_PRESENCE, &SERVED_PARTY_IPV4_ADDR, &SERVED_PARTY_IPV6_PRESENCE, &SERVED_PARTY_IPV6_ADDR)
fmt.Println(RID, IMSI, APN_PROFILE, TYPE_OF_CONTEXT, STATIC_PDN_ADDRESS_ALLOCATION, SERVED_PARTY_IPV4_PRESENCE, SERVED_PARTY_IPV4_ADDR, SERVED_PARTY_IPV6_PRESENCE, SERVED_PARTY_IPV6_ADDR)
}
//fmt.Println(*rows)
}
GO: 实例t_mysql.go
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
推荐阅读更多精彩内容
- 内容简介 今天介绍一个新的UI元素,就是当我们改变设备的方向时,我们可以看到照片的不同部分,有一种身临其境的感觉,...