Documentation ¶
Index ¶
- func ColumnsFromResultStream(rows core.ResultStream) ([]*core.Column, error)
- func NextNil() (func() (core.Row, error), func() bool)
- func NextSingle(value any) (func() (core.Row, error), func() bool)
- func NextSlice[T any](values []T, preprocess func(T) any) (func() (core.Row, error), func() bool)
- func NextYield(fn func(yield func(...any)) error) (func() (core.Row, error), func() bool)
- type Client
- func (c *Client) Close()
- func (c *Client) ColumnsFromQuery(query string, args ...any) ([]*core.Column, error)
- func (c *Client) Exec(ctx context.Context, query string) (*ResultStream, error)
- func (c *Client) Query(ctx context.Context, query string) (*ResultStream, error)
- func (c *Client) QueryUntilNotEmpty(ctx context.Context, queries ...string) (*ResultStream, error)
- func (c *Client) Swap(db *sql.DB)
- type ClientOption
- type ResultStream
- type ResultStreamBuilder
- func (b *ResultStreamBuilder) Build() *ResultStream
- func (b *ResultStreamBuilder) WithCloseFunc(fn func()) *ResultStreamBuilder
- func (b *ResultStreamBuilder) WithHeader(header core.Header) *ResultStreamBuilder
- func (b *ResultStreamBuilder) WithMeta(meta *core.Meta) *ResultStreamBuilder
- func (b *ResultStreamBuilder) WithNextFunc(fn func() (core.Row, error), has func() bool) *ResultStreamBuilder
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ColumnsFromResultStream ¶
func ColumnsFromResultStream(rows core.ResultStream) ([]*core.Column, error)
ColumnsFromResultStream converts the result stream to columns. A result stream should return rows that are at least 2 columns wide and have the following structure:
1st elem: name - string 2nd elem: type - string
func NextSingle ¶
NextSingle creates next and hasNext functions from a provided single value
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
default sql client used by other specific implementations
func (*Client) ColumnsFromQuery ¶
ColumnsFromQuery executes a given query on a new connection and converts the results to columns. A query should return a result that is at least 2 columns wide and have the following structure:
1st elem: name - string 2nd elem: type - string
Query is sprintf-ed with args, so ColumnsFromQuery("select a from %s", "table_name") works.
func (*Client) Exec ¶
Exec executes a query and returns a stream with single row (number of affected results).
func (*Client) QueryUntilNotEmpty ¶
QueryUntilNotEmpty executes given queries on a single connection and returns when one of them has a nonempty result. Useful for specifying "fallback" queries like "ROWCOUNT()" when there are no results in query.
type ClientOption ¶
type ClientOption func(*clientConfig)
func WithCustomTypeProcessor ¶
func WithCustomTypeProcessor(typ string, fn func(any) any) ClientOption
type ResultStream ¶
type ResultStream struct {
// contains filtered or unexported fields
}
func (*ResultStream) AddCallback ¶
func (r *ResultStream) AddCallback(fn func())
func (*ResultStream) Close ¶
func (r *ResultStream) Close()
func (*ResultStream) HasNext ¶
func (r *ResultStream) HasNext() bool
func (*ResultStream) Header ¶
func (r *ResultStream) Header() core.Header
func (*ResultStream) Meta ¶
func (r *ResultStream) Meta() *core.Meta
type ResultStreamBuilder ¶
type ResultStreamBuilder struct {
// contains filtered or unexported fields
}
ResultStreamBuilder builds the rows
func NewResultStreamBuilder ¶
func NewResultStreamBuilder() *ResultStreamBuilder
func (*ResultStreamBuilder) Build ¶
func (b *ResultStreamBuilder) Build() *ResultStream
func (*ResultStreamBuilder) WithCloseFunc ¶
func (b *ResultStreamBuilder) WithCloseFunc(fn func()) *ResultStreamBuilder
func (*ResultStreamBuilder) WithHeader ¶
func (b *ResultStreamBuilder) WithHeader(header core.Header) *ResultStreamBuilder
func (*ResultStreamBuilder) WithMeta ¶
func (b *ResultStreamBuilder) WithMeta(meta *core.Meta) *ResultStreamBuilder
func (*ResultStreamBuilder) WithNextFunc ¶
func (b *ResultStreamBuilder) WithNextFunc(fn func() (core.Row, error), has func() bool) *ResultStreamBuilder