sql

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 13, 2022 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Open

func Open(ctx context.Context, driver, connURL string) (storage.Driver, error)

Open sql driver connect

Types

type AbstractSyntax

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

func NewAbstractSyntax

func NewAbstractSyntax(escape string) *AbstractSyntax

func (*AbstractSyntax) DeleteQuery

func (sx *AbstractSyntax) DeleteQuery(tableName string, where WhereStmt, whereExt string) string

func (*AbstractSyntax) GetQuery

func (sx *AbstractSyntax) GetQuery(tableName string, where WhereStmt, whereExt string) string

func (*AbstractSyntax) SelectQuery

func (sx *AbstractSyntax) SelectQuery(tableName string, where WhereStmt, whereExt string) string

func (*AbstractSyntax) UpsertQuery

func (sx *AbstractSyntax) UpsertQuery(tableName string, insertFields DataFields, keyFields []string) string

type Bind

type Bind struct {
	BindAbstract
	// contains filtered or unexported fields
}

func NewBind

func NewBind(db *sqlx.DB, dbnum int, syntax Syntax, pattern, getQuery, listQuery, upsertQuery, delQuery string) *Bind

func NewBindFromTableName

func NewBindFromTableName(db *sqlx.DB, dbnum int, syntax Syntax, pattern, tableName, whereExt string, readonly bool) *Bind

func (*Bind) Del

func (b *Bind) Del(ctx context.Context, ectx keypattern.ExecContext) error

func (*Bind) Get

func (b *Bind) Get(ctx context.Context, ectx keypattern.ExecContext) (Record, error)

func (*Bind) List

func (b *Bind) List(ctx context.Context, ectx keypattern.ExecContext) ([]Record, error)

func (*Bind) Upsert

func (b *Bind) Upsert(ctx context.Context, ectx keypattern.ExecContext, value []byte) error

type BindAbstract

type BindAbstract struct {
	DBNum       int
	Pattern     *keypattern.Pattern
	Syntax      Syntax
	GetQuery    *query
	ListQuery   *query
	UpsertQuery *query
	DelQuery    *query
}

func NewBindAbstract

func NewBindAbstract(dbnum int, syntax Syntax, pattern, getQuery, listQuery, upsertQuery, delQuery string) *BindAbstract

func NewBindAbstractFromTableName

func NewBindAbstractFromTableName(dbnum int, syntax Syntax, pattern, tableName, whereExt string, readonly bool) *BindAbstract

func (*BindAbstract) Del

func (*BindAbstract) Get

func (*BindAbstract) List

func (b *BindAbstract) List(ctx context.Context, ectx keypattern.ExecContext) ([]Record, error)

func (*BindAbstract) MatchKey

func (b *BindAbstract) MatchKey(key string, ectx keypattern.ExecContext) bool

func (*BindAbstract) MatchPattern

func (b *BindAbstract) MatchPattern(pt string, ectx keypattern.ExecContext) bool

func (*BindAbstract) TableName

func (b *BindAbstract) TableName() string

func (*BindAbstract) Upsert

func (b *BindAbstract) Upsert(ctx context.Context, ectx keypattern.ExecContext, value []byte) error

type DataFields

type DataFields map[string]string

func (DataFields) Columns

func (df DataFields) Columns(escape string) string

func (DataFields) SetValues

func (df DataFields) SetValues(escape string) string

func (DataFields) Values

func (df DataFields) Values() string

type MysqlSyntax

type MysqlSyntax struct {
	AbstractSyntax
}

func NewMysqlSyntax

func NewMysqlSyntax() *MysqlSyntax

func (*MysqlSyntax) UpsertQuery

func (sx *MysqlSyntax) UpsertQuery(tableName string, insertFields DataFields, keyFields []string) string

type Query

type Query struct {
	TableName string
	// contains filtered or unexported fields
}

func ParseQuery

func ParseQuery(q string) *Query

func (*Query) Args

func (q *Query) Args(ectx keypattern.ExecContext) []interface{}

func (*Query) String

func (q *Query) String() string

type Record

type Record = storage.Record

type Syntax

type Syntax interface {
	UpsertQuery(tableName string, insertFields DataFields, keyFields []string) string
	GetQuery(tableName string, where WhereStmt, whereExt string) string
	SelectQuery(tableName string, where WhereStmt, whereExt string) string
	DeleteQuery(tableName string, where WhereStmt, whereExt string) string
}

type WhereStmt

type WhereStmt map[string]string

func (WhereStmt) Where

func (ws WhereStmt) Where(escape, whereExt string) string

Jump to

Keyboard shortcuts

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