Documentation
¶
Overview ¶
Package sqlc provides a Plax channel type for talking to a SQL database.
Index ¶
- Variables
- func NewChan(ctx *dsl.Ctx, o interface{}) (dsl.Chan, error)
- type Chan
- func (c *Chan) Close(ctx *dsl.Ctx) error
- func (c *Chan) DocSpec() *dsl.DocSpec
- func (c *Chan) Kill(ctx *dsl.Ctx) error
- func (c *Chan) Kind() dsl.ChanKind
- func (c *Chan) Open(ctx *dsl.Ctx) error
- func (c *Chan) Pub(ctx *dsl.Ctx, m dsl.Msg) error
- func (c *Chan) Recv(ctx *dsl.Ctx) chan dsl.Msg
- func (c *Chan) Sub(ctx *dsl.Ctx, topic string) error
- func (c *Chan) To(ctx *dsl.Ctx, m dsl.Msg) error
- type Input
- type Opts
Constants ¶
This section is empty.
Variables ¶
View Source
var (
DefaultChanBufferSize = 1024
)
Functions ¶
Types ¶
type Chan ¶
type Chan struct {
// contains filtered or unexported fields
}
Chan is channel type that talks to a SQL database.
When the input is a Query, the output consists of zero or more maps of strings to values, where each string is a column name, followed by a map from "hone" to the input query.
When the input is an Exec statement, the output consists of a single map with 'rowsAffected' and 'lastInsertId' keys.
type Input ¶
type Input struct {
// Query, if provided, should be a SQL statement (like SELECT)
// that returns rows.
Query string `json:"query,omitempty"`
// Exec, if provided, should be a SQL statement that doesn't
// return rows. Examples: CREATE TABLE, INSERT INTO.
Exec string `json:"exec,omitempty"`
// Args is the array of parameters for the statement.
Args []interface{} `json:"args"`
}
Input is input to a Pub operation.
type Opts ¶
type Opts struct {
// DriverName names the (Go) SQL database driver, which must
// be loaded previously (usually at compile-time or via a Go
// plug-in).
//
// This package has a cgo-free SQLite driver
// (modernc.org/sqlite) already loaded, so "sqlite" works
// here. Also see the 'mysql' subdirectory, which contains a
// package that can be compiled as a Go plug-in that provides
// a driver for MySQL.
DriverName string
// DatasourceName is the URI for the connection. See your
// driver documentation for details.
//
// You can use ":memory:" with DriverName "sqlite" to
// experiment with in in-memory, SQLite-compatible database.
DatasourceName string
// BufferSize is the size of the internal channel that queues
// results from the database. Default is
// DefaultChanBufferSize.
BufferSize int
// DriverPlugin, if given, should be the filename of a Go
// plugin for a Go SQL driver.
//
// See https://golang.org/pkg/plugin/.
//
// The subdirectory 'chans/sqlc/mysql' has an example for
// loading a MySQL driver at runtime.
DriverPlugin string
}
Opts configures an SQL channel.
DriverName and DatasourceName are per https://golang.org/pkg/database/sql/#Open.
Click to show internal directories.
Click to hide internal directories.