func (this *Iter_Amazing_SelectByName) Each(fun func(*Row_Amazing_SelectByName) error) error {
	defer this.rows.Close()
	for {
		select {
		case <-this.ctx.Done():
			return this.ctx.Err()
		default:
			if row, ok := this.Next(); !ok {
				return nil
			} else if err := fun(row); err != nil {
				return err
			}
		}
	}
}
Each performs 'fun' on each row in the result set.
Each respects the context passed to it.
It will stop iteration, and returns this.ctx.Err() if encountered.
package basic
import (
	sql "database/sql"
	driver "database/sql/driver"
	fmt "fmt"
	io "io"
	proto "github.com/golang/protobuf/proto"
	timestamp "github.com/golang/protobuf/ptypes/timestamp"
	persist "github.com/tcncloud/protoc-gen-persist/persist"
	test "github.com/tcncloud/protoc-gen-persisttests/test"
	context "golang.org/x/net/context"
	codes "google.golang.org/grpc/codes"
	gstatus "google.golang.org/grpc/status"
)
func NopPersistTx(r persist.Runnable) (persist.PersistTx, error) {
	return &ignoreTx{r}, nil
}
type ignoreTx struct {
	r persist.Runnable
}
func (this *ignoreTx) Commit() error   { return nil }
func (this *ignoreTx) Rollback() error { return nil }
func (this *ignoreTx) QueryContext(ctx context.Context, x string, ys ...interface{}) (*sql.Rows, error) {
	return this.r.QueryContext(ctx, x, ys...)
}
func (this *ignoreTx) ExecContext(ctx context.Context, x string, ys ...interface{}) (sql.Result, error) {
	return this.r.ExecContext(ctx, x, ys...)
}
type Runnable interface {
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
}
func DefaultClientStreamingPersistTx(ctx context.Context, db *sql.DB) (persist.PersistTx, error) {
	return db.BeginTx(ctx, nil)
}
func DefaultServerStreamingPersistTx(ctx context.Context, db *sql.DB) (persist.PersistTx, error) {
	return NopPersistTx(db)
}
func DefaultBidiStreamingPersistTx(ctx context.Context, db *sql.DB) (persist.PersistTx, error) {
	return NopPersistTx(db)
}
func DefaultUnaryPersistTx(ctx context.Context, db *sql.DB) (persist.PersistTx, error) {
	return NopPersistTx(db)
}
type alwaysScanner struct {
	i *interface{}
}
func (s *alwaysScanner) Scan(src interface{}) error {
	s.i = &src
	return nil
}
type scanable interface {
	Scan(...interface{}) error
	Columns() ([]string, error)
}
type Queries_Amazing struct {
	opts Opts_Amazing
}
func QueriesAmazing(opts ...Opts_Amazing) *Queries_Amazing {
	var myOpts Opts_Amazing
	if len(opts) > 0 {
		myOpts = opts[0]
	} else {
		myOpts = OptsAmazing(&DefaultHooks_Amazing{}, &DefaultTypeMappings_Amazing{})
	}
	return &Queries_Amazing{
		opts: myOpts,
	}
}
func (this *Queries_Amazing) SelectById(ctx context.Context, db persist.Runnable) *Query_Amazing_SelectById {
	return &Query_Amazing_SelectById{
		opts: this.opts,
		ctx:  ctx,
		db:   db,
	}
}
type Query_Amazing_SelectById struct {
	opts Opts_Amazing
	db   persist.Runnable
	ctx  context.Context
}
func (this *Query_Amazing_SelectById) QueryInType_PartialTable()  {}
func (this *Query_Amazing_SelectById) QueryOutType_ExampleTable() {}
func (this *Query_Amazing_SelectById) Execute(x In_Amazing_SelectById) *Iter_Amazing_SelectById {
	var setupErr error
	params := []interface{}{
		func() (out interface{}) {
			out = x.GetId()
			return
		}(),
		func() (out interface{}) {
			mapper := this.opts.MAPPINGS.TimestampTimestamp()
			out = mapper.ToSql(x.GetStartTime())
			return
		}(),
	}
	result := &Iter_Amazing_SelectById{
		tm:  this.opts.MAPPINGS,
		ctx: this.ctx,
	}
	if setupErr != nil {
		result.err = setupErr
		return result
	}
	result.rows, result.err = this.db.QueryContext(this.ctx, "SELECT * from example_table Where id=$1 AND start_time>$2", params...)
	return result
}
func (this *Queries_Amazing) SelectByName(ctx context.Context, db persist.Runnable) *Query_Amazing_SelectByName {
	return &Query_Amazing_SelectByName{
		opts: this.opts,
		ctx:  ctx,
		db:   db,
	}
}
type Query_Amazing_SelectByName struct {
	opts Opts_Amazing
	db   persist.Runnable
	ctx  context.Context
}
func (this *Query_Amazing_SelectByName) QueryInType_Name()          {}
func (this *Query_Amazing_SelectByName) QueryOutType_ExampleTable() {}
func (this *Query_Amazing_SelectByName) Execute(x In_Amazing_SelectByName) *Iter_Amazing_SelectByName {
	var setupErr error
	params := []interface{}{
		func() (out interface{}) {
			out = x.GetName()
			return
		}(),
	}
	result := &Iter_Amazing_SelectByName{
		tm:  this.opts.MAPPINGS,
		ctx: this.ctx,
	}
	if setupErr != nil {
		result.err = setupErr
		return result
	}
	result.rows, result.err = this.db.QueryContext(this.ctx, "SELECT * FROM example_table WHERE name=$1", params...)
	return result
}
func (this *Queries_Amazing) Insert(ctx context.Context, db persist.Runnable) *Query_Amazing_Insert {
	return &Query_Amazing_Insert{
		opts: this.opts,
		ctx:  ctx,
		db:   db,
	}
}
type Query_Amazing_Insert struct {
	opts Opts_Amazing
	db   persist.Runnable
	ctx  context.Context
}
func (this *Query_Amazing_Insert) QueryInType_ExampleTable() {}
func (this *Query_Amazing_Insert) QueryOutType_Empty()       {}
func (this *Query_Amazing_Insert) Execute(x In_Amazing_Insert) *Iter_Amazing_Insert {
	var setupErr error
	params := []interface{}{
		func() (out interface{}) {
			out = x.GetId()
			return
		}(),
		func() (out interface{}) {
			mapper := this.opts.MAPPINGS.TimestampTimestamp()
			out = mapper.ToSql(x.GetStartTime())
			return
		}(),
		func() (out interface{}) {
			out = x.GetName()
			return
		}(),
	}
	result := &Iter_Amazing_Insert{
		tm:  this.opts.MAPPINGS,
		ctx: this.ctx,
	}
	if setupErr != nil {
		result.err = setupErr
		return result
	}
	result.result, result.err = this.db.ExecContext(this.ctx, "INSERT INTO example_table (id, start_time, name) VALUES ($1, $2, $3)", params...)
	return result
}
type Iter_Amazing_SelectById struct {
	result sql.Result
	rows   *sql.Rows
	err    error
	tm     TypeMappings_Amazing
	ctx    context.Context
}
func (this *Iter_Amazing_SelectById) IterOutTypeTestExampleTable() {}
func (this *Iter_Amazing_SelectById) IterInTypeTestPartialTable()  {}
func (this *Iter_Amazing_SelectById) Each(fun func(*Row_Amazing_SelectById) error) error {
	defer this.rows.Close()
	for {
		select {
		case <-this.ctx.Done():
			return this.ctx.Err()
		default:
			if row, ok := this.Next(); !ok {
				return nil
			} else if err := fun(row); err != nil {
				return err
			}
		}
	}
}
func (this *Iter_Amazing_SelectById) One() *Row_Amazing_SelectById {
	first, hasFirst := this.Next()
	defer this.rows.Close()
	if first != nil && first.err != nil && first.err != io.EOF {
		return &Row_Amazing_SelectById{err: first.err}
	}
	_, hasSecond := this.Next()
	if !hasFirst || hasSecond {
		amount := "none"
		if hasSecond {
			amount = "multiple"
		}
		return &Row_Amazing_SelectById{err: persist.NotFound{Msg: fmt.Sprintf("expected exactly 1 result from query 'SelectById' found %s", amount)}}
	}
	return first
}
func (this *Iter_Amazing_SelectById) Zero() error {
	row, ok := this.Next()
	if row != nil && row.err != nil && row.err != io.EOF {
		return row.err
	}
	if ok {
		return fmt.Errorf("expected exactly 0 results from query 'SelectById'")
	}
	return nil
}
func (this *Iter_Amazing_SelectById) Next() (*Row_Amazing_SelectById, bool) {
	if this.err == io.EOF {
		return nil, false
	}
	if this.err != nil {
		err := this.err
		this.err = io.EOF
		if this.rows != nil {
			this.rows.Close()
		}
		return &Row_Amazing_SelectById{err: err}, true
	}
	if this.rows == nil {
		this.err = io.EOF
		return nil, false
	}
	cols, err := this.rows.Columns()
	if err != nil {
		return &Row_Amazing_SelectById{err: err}, true
	}
	if !this.rows.Next() {
		if this.err = this.rows.Err(); this.err == nil {
			this.err = io.EOF
			return nil, false
		} else if this.err != nil {
			return &Row_Amazing_SelectById{err: err}, true
		}
	}
	toScan := make([]interface{}, len(cols))
	scanned := make([]alwaysScanner, len(cols))
	for i := range scanned {
		toScan[i] = &scanned[i]
	}
	if this.err = this.rows.Scan(toScan...); this.err != nil {
		return &Row_Amazing_SelectById{err: this.err}, true
	}
	res := &test.ExampleTable{}
	for i, col := range cols {
		_ = i
		switch col {
		case "id":
			r, ok := (*scanned[i].i).(int64)
			if !ok {
				return &Row_Amazing_SelectById{err: fmt.Errorf("cant convert db column id to protobuf go type ")}, true
			}
			res.Id = int64(r)
		case "start_time":
			var converted = this.tm.TimestampTimestamp()
			if err := converted.Scan(*scanned[i].i); err != nil {
				return &Row_Amazing_SelectById{err: fmt.Errorf("could not convert mapped db column start_time to type on test.ExampleTable.StartTime: %v", err)}, true
			}
			if err := converted.ToProto(&res.StartTime); err != nil {
				return &Row_Amazing_SelectById{err: fmt.Errorf("could not convert mapped db column start_timeto type on test.ExampleTable.StartTime: %v", err)}, true
			}
		case "name":
			r, ok := (*scanned[i].i).(string)
			if !ok {
				return &Row_Amazing_SelectById{err: fmt.Errorf("cant convert db column name to protobuf go type ")}, true
			}
			res.Name = r
		default:
			return &Row_Amazing_SelectById{err: fmt.Errorf("unsupported column in output: %s", col)}, true
		}
	}
	return &Row_Amazing_SelectById{item: res}, true
}
func (this *Iter_Amazing_SelectById) Slice() []*Row_Amazing_SelectById {
	var results []*Row_Amazing_SelectById
	for {
		if i, ok := this.Next(); ok {
			results = append(results, i)
		} else {
			break
		}
	}
	return results
}
func (r *Iter_Amazing_SelectById) Columns() ([]string, error) {
	if r.err != nil {
		return nil, r.err
	}
	if r.rows != nil {
		return r.rows.Columns()
	}
	return nil, nil
}
type Iter_Amazing_SelectByName struct {
	result sql.Result
	rows   *sql.Rows
	err    error
	tm     TypeMappings_Amazing
	ctx    context.Context
}
func (this *Iter_Amazing_SelectByName) IterOutTypeTestExampleTable() {}
func (this *Iter_Amazing_SelectByName) IterInTypeTestName()          {}