Created
March 27, 2014 08:19
-
-
Save changsijay/9802801 to your computer and use it in GitHub Desktop.
golang mysql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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