import ( "github.com/qleelulu/goku/mysql" ) func main() { db, err := mysql.Open("root:password@tcp(127.0.0.1:3306)/database_name") if err != nil { log.Fatal(err) } defer db.Close() }
rows, err := db.Query("SELECT * FROM table_name WHERE id=?", 123) if err != nil { log.Fatal(err) } defer rows.Close() for rows.Next() { var id int var name string if err := rows.Scan(&id, &name); err != nil { log.Fatal(err) } fmt.Println(id, name) }
var name string err := db.QueryRow("SELECT name FROM table_name WHERE id=?", 123).Scan(&name) if err != nil { log.Fatal(err) } fmt.Println(name)Overall, the go github.com.qleelulu.goku MysqlDB package provides a convenient and efficient way to interact with MySQL databases in Go applications.