sql

package
v0.0.0-...-bab53cf Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2019 License: Apache-2.0 Imports: 23 Imported by: 0

README

SQLFlow

Build, Run, Test

Before running the unit tests, we need to build and run a Docker container that hosts a MySQL database following this guide.

To build the parser using goyacc and run all unit tests, use the following command:

go get -d ./... && goyacc -p sql -o parser.go sql.y && go test -v

Documentation

Index

Constants

View Source
const AND = 57360
View Source
const COLUMN = 57353
View Source
const FROM = 57347
View Source
const GE = 57362
View Source
const IDENT = 57357
View Source
const INTO = 57356
View Source
const LABEL = 57354
View Source
const LE = 57363
View Source
const LIMIT = 57349
View Source
const NOT = 57364
View Source
const NUMBER = 57358
View Source
const OR = 57361
View Source
const POWER = 57365
View Source
const PREDICT = 57351
View Source
const SELECT = 57346
View Source
const STRING = 57359
View Source
const TRAIN = 57350
View Source
const UMINUS = 57366
View Source
const USING = 57355
View Source
const WHERE = 57348
View Source
const WITH = 57352

Variables

View Source
var ErrClosedPipe = errors.New("pipe: write on closed pipe")

Functions

func Pipe

func Pipe() (*PipeReader, *PipeWriter)

Pipe creates a synchronous in-memory pipe.

It is safe to call Read and Write in parallel with each other or with Close. Parallel calls to Read and parallel calls to Write are also safe: the individual calls will be gated sequentially.

Types

type DB

type DB struct {
	*sql.DB
	// contains filtered or unexported fields
}

DB extends sql.DB

func Open

func Open(driverName, dataSourceName string) (*DB, error)

Open opens a database specified by its database driver name and a driver-specific data source name, usually consisting of at least a database name and connection information.

In addition to sql.Open, it also does the book keeping on driverName and dataSourceName

type PipeReader

type PipeReader struct {
	// contains filtered or unexported fields
}

PipeReader reads real data

func Run

func Run(slct string, db *DB) *PipeReader

Run executes a SQL query and returns a stream of row or message

func (*PipeReader) Close

func (r *PipeReader) Close()

Close closes the reader; subsequent writes to the

func (*PipeReader) ReadAll

func (r *PipeReader) ReadAll() chan interface{}

ReadAll returns the data chan. The caller should use it as `for r := range pr.ReadAll()`

type PipeWriter

type PipeWriter struct {
	// contains filtered or unexported fields
}

PipeWriter writes real data

func (*PipeWriter) Close

func (w *PipeWriter) Close()

Close closes the writer; subsequent ReadAll from the read half of the pipe will return a closed channel.

func (*PipeWriter) Write

func (w *PipeWriter) Write(item interface{}) error

Write writes the item to the underlying data stream. It returns ErrClosedPipe when the data stream is closed.

Jump to

Keyboard shortcuts

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