go执行基本数据库操作
package main import ( "database/sql" "fmt" _ "github.com/go-sql-driver/mysql" ) func main() { //打开连接 db, _ := sql.Open("mysql", "root:123456@/test?charset=utf8") //执行查询 rows, _ := db.Query("select ename from emp") //处理结果集 for rows.Next() { var ename string rows.Scan(&ename) fmt.Println(ename) } //关闭连接 db.Close() }