modulepackage
0.0.0-20231010082101-5e2cfb777f9a
Repository: https://github.com/ccmonky/sqlkit.git
Documentation: pkg.go.dev
# README
sqlkit
sql kits
TODO
- mysql knowledge engineering and
- mysql expert experience(e.g. performance_schema)
- sql mock recorder
- sql rewrite
- sql flow control
- sql metrics & automatic profiling
- sql distributed lock
- distributed transaction
# Packages
No description provided by the author
# Functions
ConvertAssign is the same as convertAssignRows, but without the optional rows argument.
DefaultShouldAudit sql是否审计的默认实现.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
NewSyncMap creates a new map.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
Wrap is used to create a new instrumented driver, it takes a vendor specific driver, and a Hooks instance to produce a new driver instance.
# Constants
Alarm warning, means index missing but the number of scan lines is not large, still let the sql go through.
Banned banned, means index missing and the number of scan lines is not large, still let the sql will be banned.
MysqlAuditDriverName msyql+audit database driver name.
Normal normal, means not alarm.
# Variables
App app name.
CSVColumnParser is a function which converts trimmed csv column string to a []byte representation.
DefaultAlarmThreshold default alarm threshold(scan rows).
DefaultBannedThreshold default banned threshold(scan rows).
DefaultSeenSqlLogLevel default log level for seen sql.
ErrAlarm sql warning, use errors.Is(err, ErrAlarm) to assert.
ErrBanned sql banned error, use errors.Is(err, ErrBanned) to assert.
used for test.
# Structs
No description provided by the author
Audit audit sqls and alarm or ban according to some conditions
Usage:
import ( sql "database/sql"
"github.com/qustavo/sqlhooks/v2" "github.com/go-sql-driver/mysql"
"gitlab.alibaba-inc.com/t3/pkg/sqlkit" )
audit := &sqlkit.Audit{ DatabaseName: "xxx", } err := audit.Provision(ctx) sql.Register(sql.DriverName, sqlhooks.Wrap(&mysql.MySQLDriver{}, audit)) db, err := sql.Open(sqlkit.DriverName, ...) err = audit.SetDB(db) // NOTE: reuse the same pool err = audit.Validate() // if err == nil, then you can use the db ..
No description provided by the author
Conn implements a database/sql.driver.Conn.
Driver implements a database/sql/driver.Driver.
No description provided by the author
ExecerContext implements a database/sql.driver.ExecerContext.
ExecerQueryerContext implements database/sql.driver.ExecerContext and database/sql.driver.QueryerContext.
ExecerQueryerContext implements database/sql.driver.ExecerContext and database/sql.driver.QueryerContext.
LogHooks log sqls with rt and traceid.
No description provided by the author
QueryerContext implements a database/sql.driver.QueryerContext.
No description provided by the author
Rewrite an aggregate rewriter, usually can be used in most cases.
No description provided by the author
Rows mainly copy from `sqlmock`, and used with `sqlkit.Mock` Experimental!!!.
No description provided by the author
No description provided by the author
Sql sql statement.
Stmt implements a database/sql/driver.Stmt.
No description provided by the author
# Interfaces
No description provided by the author
Middleware is a middleware which wrap a driver to another This work is based on `sqlhooks`, why define a new `Hook`? For `sqlhooks.Hooks` can not operate the arguments & returns but only ctx, which is not applicable for some scenarios, e.g.
No description provided by the author
No description provided by the author
No description provided by the author
# Type aliases
AlarmType alarm type.
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author