Go?????????MySql?????
???????????? ???????[ 2015/12/7 11:37:06 ] ?????????????
??????????????????????database/sql??????????????????????
package main
import (
_ "github.com/Go-SQL-Driver/MySQL"
"database/sql"
"fmt"
//"time"
)
func main() {
db?? err := sql.Open("mysql"?? "astaxie:astaxie@/test?charset=utf8")
checkErr(err)
//????????
stmt?? err := db.Prepare("INSERT userinfo SET username=???departname=???created=?")
checkErr(err)
res?? err := stmt.Exec("astaxie"?? "?з?????"?? "2012-12-09")
checkErr(err)
id?? err := res.LastInsertId()
checkErr(err)
fmt.Println(id)
//????????
stmt?? err = db.Prepare("update userinfo set username=? where uid=?")
checkErr(err)
res?? err = stmt.Exec("astaxieupdate"?? id)
checkErr(err)
affect?? err := res.RowsAffected()
checkErr(err)
fmt.Println(affect)
//???????
rows?? err := db.Query("SELECT * FROM userinfo")
checkErr(err)
for rows.Next() {
var uid int
var username string
var department string
var created string
err = rows.Scan(&uid?? &username?? &department?? &created)
checkErr(err)
fmt.Println(uid)
fmt.Println(username)
fmt.Println(department)
fmt.Println(created)
}
//???????
stmt?? err = db.Prepare("delete from userinfo where uid=?")
checkErr(err)
res?? err = stmt.Exec(id)
checkErr(err)
affect?? err = res.RowsAffected()
checkErr(err)
fmt.Println(affect)
db.Close()
}
func checkErr(err error) {
if err != nil {
panic(err)
}
}
???????????????????????????Go????Mysql?????????????
???????????????????????£?
????sql.Open()??????????????????????????????Go-MySQL-Driver???????mysql?????????????????????????DNS(Data Source Name)??????Go-MySQL-Driver??????Щ????????????????????????????????
????user@unix(/path/to/socket)/dbname?charset=utf8
????user:password@tcp(localhost:5555)/dbname?charset=utf8
????user:password@/dbname
????user:password@tcp([de:ad:be:ef::ca:fe]:80)/dbname
????db.Prepare()??????????????????е?sql?????????????????????????
????db.Query()??????????????Sql????Rows?????
????stmt.Exec()???????????stmt??????SQL???
?????????????????????????????=???????????????????????????????????SQL???
???????????????????????漰???????????????????SPASVOС??(021-61079698-8054)?????????????????????????
??????
???mysql?????????????mysql????? distinct?÷?MySQL?н???????????з??Mysql?????????MySQL Cluster??δ????????????????ν?MySQL??????????300???????MySQL???Uber???????????????????MySql SQL??????????MySQL?????????????????λЧ?????SQL???Java???????:?????MySQL???????linux?°??mysql????MySQL ???????????????????binlog??MySQL????????????Щ??????MySQL???????Mysql???????JDBC?????mysql?????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11????????
?????????App Bug???????????????????????Jmeter?????????QC??????APP????????????????app?????е????????jenkins+testng+ant+webdriver??????????????JMeter????HTTP???????Selenium 2.0 WebDriver ??????