Skip to content

Instantly share code, notes, and snippets.

@freeeve
Created January 4, 2014 00:16
Show Gist options
  • Save freeeve/8249430 to your computer and use it in GitHub Desktop.
Save freeeve/8249430 to your computer and use it in GitHub Desktop.
package main
import (
"database/sql"
"fmt"
_ "github.com/wfreeman/pq"
)
func main() {
conn, err := sql.Open("postgres", "host=/tmp/ sslmode=disable")
if err != nil {
fmt.Println(err)
}
rows, err := conn.Query("select * from test where test.name=$1", "asdf")
if err != nil {
fmt.Println(err)
}
defer rows.Close()
var result int
for rows.Next() {
err = rows.Scan(&result)
if err != nil {
fmt.Println(err)
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment