Skip to content

Instantly share code, notes, and snippets.

@changsijay
Created March 27, 2014 08:19
Show Gist options
  • Save changsijay/9802801 to your computer and use it in GitHub Desktop.
Save changsijay/9802801 to your computer and use it in GitHub Desktop.
golang mysql
package main
import (
"fmt"
"database/sql"
_ "github.com/go-sql-driver/mysql"
)
func main() {
fmt.Println("Connect to mysql now")
db, _ := sql.Open("mysql", "account:password@tcp(host:3306)/db")
defer db.Close()
var sku_name string
results, _ := db.Query("sql_cmd")
defer db.Close()
for results.Next() {
results.Scan(&sku_name)
fmt.Println(sku_name)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment