dynsql

package module
v0.0.0-...-9d8e397 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2019 License: MIT Imports: 8 Imported by: 0

README

dynsql

Dynamic SQL-backed database interface. Imagine just putting JSON into tables which magically expand.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InsertJSONStatementHeads = []string{"INSERT INTO", "Insert Into", "insert into"}
	InsertJSONStatementRegex = regexp.MustCompile(`^(INSERT INTO|Insert Into|insert into)\s*(?P<TABLE>[\w\d\_]+)\s*(JSON|Json|json)\s*(?P<JSON>.*)\s*(\;*)$`)
)
View Source
var (
	ErrFailedToParseString = errors.New("failed to parse string")
)

Functions

This section is empty.

Types

type Conn

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

func (*Conn) Begin

func (c *Conn) Begin() (driver.Tx, error)

func (*Conn) Close

func (c *Conn) Close() error

func (*Conn) Exec

func (c *Conn) Exec(query string, args []driver.Value) (driver.Result, error)

func (*Conn) Prepare

func (c *Conn) Prepare(query string) (driver.Stmt, error)

func (*Conn) PrepareContext

func (c *Conn) PrepareContext(ctx context.Context, query string) (driver.Stmt, error)

func (*Conn) Query

func (c *Conn) Query(query string, args []driver.Value) (driver.Rows, error)

type Driver

type Driver struct {
	SQL SQLDialect
	// contains filtered or unexported fields
}

func WrapDriver

func WrapDriver(baseDriver driver.Driver, sql SQLDialect) *Driver

func (*Driver) Open

func (d *Driver) Open(name string) (driver.Conn, error)

type ExecerQueryer

type ExecerQueryer interface {
	driver.Queryer
	driver.Execer
}

type ExecerQueryerPreparer

type ExecerQueryerPreparer interface {
	ExecerQueryer
	Prepare(query string) (driver.Stmt, error)
}

type JSONType

type JSONType string
var (
	JSONString  JSONType = "string"
	JSONNumber  JSONType = "number"
	JSONBoolean JSONType = "boolean"
)

type SQLDialect

type SQLDialect interface {
	GetAllTableNames(x ExecerQueryer) ([]string, error)
	GetAllTableColumns(tableName string, x ExecerQueryer) (map[string]string, error)

	CreateNewTable(table string, keys []string, types []JSONType, x ExecerQueryer) error
	AddColumnToTable(table, key string, t JSONType, x ExecerQueryer) error

	InsertValuesPrepare(table string, keys []string, x ExecerQueryerPreparer) (driver.Stmt, error)
}

type Stmt

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

func (*Stmt) Close

func (s *Stmt) Close() (err error)

func (*Stmt) Exec

func (s *Stmt) Exec(args []driver.Value) (driver.Result, error)

func (*Stmt) NumInput

func (s *Stmt) NumInput() int

func (*Stmt) Query

func (s *Stmt) Query(args []driver.Value) (driver.Rows, error)

Directories

Path Synopsis
lib
x

Jump to

Keyboard shortcuts

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