sqlplus

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 19, 2022 License: Apache-2.0 Imports: 3 Imported by: 2

README

sqlplus

Godoc Go Report Card Release codecov Download GitHub

A sql enhancement tool library based on database/sql/driver

😜installation

go get -u github.com/chenquan/sqlplus

👏how to use

Implement the sqlplus.Hook interface and wrap it with sqlplus.New(d driver.Driver, hook Hook) driver.Driver

👐ecosystem

  • sqltrace: A low-code intrusion library that provides SQL tracing capabilities, suitable for any relational database (Sqlite3, MySQL, Oracle, SQL Server, PostgreSQL, TiDB, etc.) and ORM libraries for various relational database (gorm, xorm, sqlx, etc.)
  • sqlbreaker: A low-code intrusion library that provides SQL breaker capabilities, suitable for any relational database (Sqlite3, MySQL, Oracle, SQL Server, PostgreSQL, TiDB, etc.) and ORM libraries for various relational database (gorm, xorm, sqlx, etc.)

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func New

func New(d driver.Driver, hook Hook) driver.Driver

func PrepareContextFromContext

func PrepareContextFromContext(ctx context.Context) context.Context

func TxContextFromContext

func TxContextFromContext(ctx context.Context) context.Context

Types

type ConnHook

type ConnHook interface {
	BeforeExecContext(ctx context.Context, query string, args []driver.NamedValue, err error) (context.Context, string, []driver.NamedValue, error)
	AfterExecContext(ctx context.Context, query string, args []driver.NamedValue, dr driver.Result, err error) (context.Context, driver.Result, error)

	BeforeBeginTx(ctx context.Context, opts driver.TxOptions, err error) (context.Context, driver.TxOptions, error)
	AfterBeginTx(ctx context.Context, opts driver.TxOptions, dt driver.Tx, err error) (context.Context, driver.Tx, error)

	BeforeQueryContext(ctx context.Context, query string, args []driver.NamedValue, err error) (context.Context, string, []driver.NamedValue, error)
	AfterQueryContext(ctx context.Context, query string, args []driver.NamedValue, rows driver.Rows, err error) (context.Context, driver.Rows, error)

	BeforePrepareContext(ctx context.Context, query string, err error) (context.Context, string, error)
	AfterPrepareContext(ctx context.Context, query string, ds driver.Stmt, err error) (context.Context, driver.Stmt, error)
	BeforeClose(ctx context.Context, err error) (context.Context, error)
	AfterClose(ctx context.Context, err error) (context.Context, error)
}

type ConnectorHook

type ConnectorHook interface {
	BeforeConnect(ctx context.Context, err error) (context.Context, error)
	AfterConnect(ctx context.Context, dc driver.Conn, err error) (context.Context, driver.Conn, error)
}

type Hook

type Hook interface {
	ConnectorHook
	ConnHook
	TxHook
	StmtHook
}

func NewMultiHook

func NewMultiHook(hooks ...Hook) Hook

type StmtHook

type StmtHook interface {
	BeforeStmtQueryContext(ctx context.Context, query string, args []driver.NamedValue, err error) (context.Context, []driver.NamedValue, error)
	AfterStmtQueryContext(ctx context.Context, query string, args []driver.NamedValue, rows driver.Rows, err error) (context.Context, driver.Rows, error)
	BeforeStmtExecContext(ctx context.Context, query string, args []driver.NamedValue, err error) (context.Context, []driver.NamedValue, error)
	AfterStmtExecContext(ctx context.Context, query string, args []driver.NamedValue, r driver.Result, err error) (context.Context, driver.Result, error)
}

type TxHook

type TxHook interface {
	BeforeCommit(ctx context.Context, err error) (context.Context, error)
	AfterCommit(ctx context.Context, err error) (context.Context, error)
	BeforeRollback(ctx context.Context, err error) (context.Context, error)
	AfterRollback(ctx context.Context, err error) (context.Context, error)
}

Jump to

Keyboard shortcuts

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