top

SQL Relational Database Client.

A query is defined through a *Command. Do not create a new *Command structure every time a query is run, but create a *Command for each query once. Once created a *Command structure shouldn't be modified while it might be used.

The Arity field in *Command controls how the number of rows are handled. If the Arity is zero, the result is automatically closed after execution. If the Arity is one, the result is closed after reading the first row.

Depending on the driver, the name fields "N" may be optional and the order of of the parameters or values used. Refer to each driver's documentation for more information. To pass in a NULL parameter, use "rdb.TypeNull" as the value.

Result.Prep should be called before Scan on each row. To prepare multiple values Result.Scan(...) can be used to scan into value by index all at once. Some drivers will support io.Writer for some data types. If a value is not prep'ed, the value will be stored in a row buffer until the next Result.Scan().

Simple example:

cmd := &rdb.Command{
	Sql: `select * from Account where ID = :ID;`,
	Arity: rdb.OneMust,
}
res, err := db.Query(cmd, rdb.Param{Name: "ID", Value: 2})
if err != nil {
	return err
}
// Next() is not required.
var id int
err = res.Scan(&id)
if err != nil {
	return err
}

Imported by 12 package(s)

  1. bitbucket.org/kardianos/rdb/ms
  2. bitbucket.org/kardianos/rdb/ms/batch
  3. bitbucket.org/kardianos/rdb/must
  4. bitbucket.org/kardianos/rdb/pg
  5. bitbucket.org/kardianos/rdb/sql
  6. bitbucket.org/kardianos/rdb/table
  7. github.com/AduroIdea/goracle/rdbdrv
  8. github.com/go-goracle/goracle/rdbdrv
  9. github.com/tgulacsi/goracle/rdbdrv
  10. github.com/vsdutka/goracle-1/rdbdrv
  11. github.com/vsdutka/goracle/rdbdrv
  12. gopkg.in/goracle.v1/rdbdrv

Imports 4 package(s)

  1. github.com/youtube/vitess/go/pools
  2. golang.org/x/net/context
  3. github.com/pkg/errors
  4. bitbucket.org/kardianos/rdb/semver