Created
March 12, 2013 13:16
-
-
Save peterbourgon/5142785 to your computer and use it in GitHub Desktop.
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 ( | |
"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