时间:2021-07-01 10:21:17 帮助过:39人阅读
2.数据库查询
//数据库单条查询 func DbQueryRow(db *sql.DB, str string) (result string, err error){ row_err := db.QueryRow(str).Scan(&result) if row_err != nil (){ }else{ } return } //数据库一般查询 //数据库单条查询 func DbQueryRow(db *sql.DB, str string) (rows *sql.Rows, err error){ rows ,row_err := db.Query(str) if row_err != nil (){ }else{ } return }
//对rows处理for rows.Next() {
var uid int
var name, password stringrows.Scan(&uid, &name, &password)
fmt.Println("uid:", uid, "name:", name, "password:", password)
}
Golang 数据库操作
标签:turn 数据库查询 host uid for tcp user 返回 utf8