1
// Copyright 2013 The Go Authors. All rights reserved.
2
// Use of this source code is governed by a BSD-style
3
// license that can be found in the LICENSE file.
15
func ExampleDB_Query() {
17
rows, err := db.Query("SELECT name FROM users WHERE age=?", age)
23
if err := rows.Scan(&name); err != nil {
26
fmt.Printf("%s is %d\n", name, age)
28
if err := rows.Err(); err != nil {
33
func ExampleDB_QueryRow() {
36
err := db.QueryRow("SELECT username FROM users WHERE id=?", id).Scan(&username)
38
case err == sql.ErrNoRows:
39
log.Printf("No user with that ID.")
43
fmt.Printf("Username is %s\n", username)