sqlc

package
v0.8.32 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 21, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package sqlc provides a Plax channel type for talking to a SQL database.

Index

Constants

This section is empty.

Variables

View Source
var (
	DefaultChanBufferSize = 1024
)

Functions

func NewChan

func NewChan(ctx *dsl.Ctx, o interface{}) (dsl.Chan, error)

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.

func (*Chan) Close

func (c *Chan) Close(ctx *dsl.Ctx) error

func (*Chan) DocSpec

func (c *Chan) DocSpec() *dsl.DocSpec

func (*Chan) Kill

func (c *Chan) Kill(ctx *dsl.Ctx) error

func (*Chan) Kind

func (c *Chan) Kind() dsl.ChanKind

func (*Chan) Open

func (c *Chan) Open(ctx *dsl.Ctx) error

func (*Chan) Pub

func (c *Chan) Pub(ctx *dsl.Ctx, m dsl.Msg) error

func (*Chan) Recv

func (c *Chan) Recv(ctx *dsl.Ctx) chan dsl.Msg

func (*Chan) Sub

func (c *Chan) Sub(ctx *dsl.Ctx, topic string) error

func (*Chan) To

func (c *Chan) To(ctx *dsl.Ctx, m dsl.Msg) error

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.

Directories

Path Synopsis
Package main exists to act as a Go plug-in for a MySQL driver for the Plax SQL channel type.
Package main exists to act as a Go plug-in for a MySQL driver for the Plax SQL channel type.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL