Skip to content

Instantly share code, notes, and snippets.

@peterbourgon
Created March 12, 2013 13:16
Show Gist options
  • Save peterbourgon/5142785 to your computer and use it in GitHub Desktop.
Save peterbourgon/5142785 to your computer and use it in GitHub Desktop.
package main
import (
"database/sql"
"flag"
"fmt"
_ "github.com/Go-SQL-Driver/MySQL"
)
var (
dsn = flag.String("dsn", "", "DSN connect string")
)
func init() {
flag.Parse()
}
func main() {
db, err := sql.Open("mysql", *dsn)
if err != nil {
panic(err)
}
id := 2
var list string
err = db.QueryRow("SELECT list FROM live WHERE user_id = ?", id).Scan(&list)
if err != nil {
panic(err)
}
fmt.Printf("%v\n", list)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment