Documentation ¶
Index ¶
- Constants
- Variables
- func AbbreviateSlice(r []any, maxLen int) []any
- func AutoTestConnect(dsnSource string) (driverName, fixedDataSourceName string)
- func Exec(ctx context.Context, db DBExecAware, q string, args []any, ...) error
- func FirstTimeQuery(query string, tags []*Pos) string
- func FormatFloat64(f float64) string
- func FullQuery(query string, tags []*Pos) string
- func GetBindPlaceholder(driverName string) func(seq int) string
- func GoWait(threads int, f func(threadNum int) error, errHandler func(error)) time.Duration
- func IsUsingDB(q string) bool
- func NewCachingSubstituter() jj.Substitute
- func NewUpdateRowsScanner() *updateRowsScanner
- func Parse(sql string, dbDialect dialect.Dialect, mode sqlparser.Mode) (sqlparser.Statement, error)
- func ParseBool(s string, defaultValue bool) bool
- func ParseSQL(placeholder BindNameAware, sql string) (parsedQuery sqlparser.Statement, varSubs []ss.Subs, err error)
- func ParseSubstitute(s string) (parts ss.Parts)
- func PingDB(ctx context.Context, db any, timeout time.Duration) error
- func Query(ctx context.Context, db sqlmap.Queryer, q string, args []any, ...) error
- func ReadEnvFile(filename string) (envMap map[string][]string, err error)
- func RepeatValues(values string, fn BindNameAware, batch int) string
- func RunSQL(ctx context.Context, db DB, driverName, q string, option RunSQLOption) error
- func WithSignal(ctx context.Context, timeout time.Duration, sig ...os.Signal) (context.Context, context.CancelFunc)
- type Action
- type Bar
- type Batch
- type BindNameAware
- type BindNameMssql
- type BindNameMySQL
- type BindNameOracle
- type BindNamePg
- type ColName
- type Config
- type DB
- type DBExecAware
- type DSNItem
- type DataSource
- type DisplayMode
- type DsSql
- type FindOption
- type FuncExpr
- type HTTPRowsScanner
- type InsertRowsScanner
- type JsonRowsScanner
- type LogOption
- type LogState
- type ParseResult
- type Perf
- type Pos
- type QueryRowsStepper
- type RunSQLOption
- type SQLVal
- type Seq
- type Sql
- type SubVars
- type TableRowsScanner
- type Tx
- type TxAware
- type TxContextAware
Constants ¶
View Source
const ( DisplayDefault = 1 << iota // 1 << 0 which is 00000001 DisplayVertical DisplayInsertSQL DisplayJSON DisplayJSONFree )
Variables ¶
View Source
var UsingPing = ParseBool(os.Getenv("PING"), true)
Functions ¶
func AbbreviateSlice ¶
func AutoTestConnect ¶
func Exec ¶
func Exec(ctx context.Context, db DBExecAware, q string, args []any, rowsScanner sqlmap.RowsScanner) error
func FirstTimeQuery ¶
func FormatFloat64 ¶
FormatFloat64 formats a float64 number to a string with the specified precision. If the fractional part is all zeros, it returns the integer part only.
func GetBindPlaceholder ¶
func NewCachingSubstituter ¶
func NewCachingSubstituter() jj.Substitute
func NewUpdateRowsScanner ¶
func NewUpdateRowsScanner() *updateRowsScanner
func ParseBool ¶
ParseBool returns the boolean value represented by the string. It accepts 1, t, true, y, yes, on as true with camel case incentive and accepts 0, f false, n, no, off as false with camel case incentive Any other value returns an error.
func ParseSQL ¶
func ParseSQL(placeholder BindNameAware, sql string) (parsedQuery sqlparser.Statement, varSubs []ss.Subs, err error)
ParseSQL returns a normalized (lowercase's SQL commands) SQL string, and redacted SQL string with the params stripped out for display. Taken from sqlparser package
func ParseSubstitute ¶
func RepeatValues ¶
func RepeatValues(values string, fn BindNameAware, batch int) string
Types ¶
type Action ¶
type Action struct { LabelQuery string `yaml:"labelQuery"` Sqls []*Sql `yaml:"sqls"` Disabled bool `yaml:"disabled"` // contains filtered or unexported fields }
func (*Action) Go ¶
func (a *Action) Go(dss []*DataSource, r *replOptions) (namedSqls []DsSql)
type BindNameAware ¶
type BindNameMssql ¶
type BindNameMssql struct {
Seq
}
func (*BindNameMssql) BindName ¶
func (s *BindNameMssql) BindName(seq int) string
func (*BindNameMssql) GetDialect ¶
func (s *BindNameMssql) GetDialect() dialect.Dialect
func (*BindNameMssql) NextBindName ¶
func (s *BindNameMssql) NextBindName() string
type BindNameMySQL ¶
type BindNameMySQL struct {
Seq
}
func (*BindNameMySQL) BindName ¶
func (s *BindNameMySQL) BindName(seq int) string
func (*BindNameMySQL) GetDialect ¶
func (s *BindNameMySQL) GetDialect() dialect.Dialect
func (*BindNameMySQL) NextBindName ¶
func (s *BindNameMySQL) NextBindName() string
type BindNameOracle ¶
type BindNameOracle struct {
Seq
}
func (*BindNameOracle) BindName ¶
func (s *BindNameOracle) BindName(seq int) string
func (*BindNameOracle) GetDialect ¶
func (s *BindNameOracle) GetDialect() dialect.Dialect
func (*BindNameOracle) NextBindName ¶
func (s *BindNameOracle) NextBindName() string
type BindNamePg ¶
type BindNamePg struct {
Seq
}
func (*BindNamePg) BindName ¶
func (s *BindNamePg) BindName(seq int) string
func (*BindNamePg) GetDialect ¶
func (s *BindNamePg) GetDialect() dialect.Dialect
func (*BindNamePg) NextBindName ¶
func (s *BindNamePg) NextBindName() string
type ColName ¶
func (*ColName) Format ¶
func (node *ColName) Format(buf *sqlparser.TrackedBuffer)
Format formats the node.
type Config ¶
type Config struct { Prompt string `yaml:"prompt" default:"always"` ListenAddr string `yaml:"listenAddr"` ContextPath string `yaml:"contextPath" default:"/"` DataSources []*DataSource `yaml:"dataSources"` Actions []*Action `yaml:"actions"` Offset int `yaml:"offset"` Limit int `yaml:"limit" default:"1000"` }
func ParseConfigFile ¶
type DB ¶
type DB interface { sqlmap.Queryer DBExecAware }
type DBExecAware ¶
type DataSource ¶
type DataSource struct { Labels map[string]string `yaml:"labels"` Name string `yaml:"name"` DriverName string `yaml:"driverName"` DataSourceURL string `yaml:"dataSourceName"` DataSourceEnv string `yaml:"dataSourceEnv"` Disabled bool `yaml:"disabled"` // contains filtered or unexported fields }
func (*DataSource) Close ¶
func (d *DataSource) Close() error
func (*DataSource) Connect ¶
func (d *DataSource) Connect(panicOnError bool, verbose int, maxOpenConns int) (err error)
func (*DataSource) GetDataSourceName ¶
func (d *DataSource) GetDataSourceName() string
func (*DataSource) ItemDesc ¶
func (d *DataSource) ItemDesc() string
func (*DataSource) ItemTitle ¶
func (d *DataSource) ItemTitle() string
type DisplayMode ¶
type DisplayMode int
type DsSql ¶
type DsSql struct { DS *DataSource *Sql }
type FindOption ¶
func (*FindOption) FindNamed ¶
func (f *FindOption) FindNamed(s string) (names []*Pos)
func (*FindOption) FindTags ¶
func (f *FindOption) FindTags(s string) (tags []*Pos)
type FuncExpr ¶
func (*FuncExpr) Format ¶
func (node *FuncExpr) Format(buf *sqlparser.TrackedBuffer)
Format formats the node.
type HTTPRowsScanner ¶
type HTTPRowsScanner struct { Header []string Limit, Offset int // contains filtered or unexported fields }
func NewHTTPRowsScanner ¶
func NewHTTPRowsScanner(limit, offset int, writer io.Writer) *HTTPRowsScanner
func (*HTTPRowsScanner) Complete ¶
func (j *HTTPRowsScanner) Complete()
func (*HTTPRowsScanner) StartExecute ¶
func (j *HTTPRowsScanner) StartExecute(string)
type InsertRowsScanner ¶
type InsertRowsScanner struct { Header []string Limit, Offset int // contains filtered or unexported fields }
func NewInsertRowsScanner ¶
func NewInsertRowsScanner(limit, offset int) *InsertRowsScanner
func (*InsertRowsScanner) AddRow ¶
func (j *InsertRowsScanner) AddRow(rowIndex int, columns []any) bool
func (*InsertRowsScanner) Complete ¶
func (j *InsertRowsScanner) Complete()
func (*InsertRowsScanner) SingleQuote ¶
func (j *InsertRowsScanner) SingleQuote() bool
func (*InsertRowsScanner) StartExecute ¶
func (j *InsertRowsScanner) StartExecute(query string)
type JsonRowsScanner ¶
type JsonRowsScanner struct { Header []string Limit, Offset int Vertical bool FreeInnerJSON bool // contains filtered or unexported fields }
func NewJsonRowsScanner ¶
func NewJsonRowsScanner(offset, limit int, vertical, freeInnerJSON bool) *JsonRowsScanner
func (*JsonRowsScanner) Complete ¶
func (j *JsonRowsScanner) Complete()
func (*JsonRowsScanner) StartExecute ¶
func (j *JsonRowsScanner) StartExecute(string)
type LogOption ¶
func ParseLogOptions ¶
type ParseResult ¶
type QueryRowsStepper ¶
func (*QueryRowsStepper) HasNext ¶
func (s *QueryRowsStepper) HasNext() bool
type RunSQLOption ¶
type RunSQLOption struct { RowsScanner sqlmap.RowsScanner Lookup map[string]map[string]string Format string RawFileDir string RawFileExt string Offset, Limit int DisplayMode int Timeout time.Duration // SQL 执行超时时间 MaxLen int PrintCost bool SaveResult bool TempResultDB bool ShowRowIndex bool NoEvalSQL bool // 评估 SQL,提取常量为占位符,估算 @name 值等 DryRun bool ParsePrepared bool AsQuery bool // 强制作为 query 执行(有结果集处理) AsExec bool // 强制作为 更新执行(不处理结果集) }
func (*RunSQLOption) GetRowsScanner ¶
func (r *RunSQLOption) GetRowsScanner() sqlmap.RowsScanner
type SQLVal ¶
func (*SQLVal) Format ¶
func (node *SQLVal) Format(buf *sqlparser.TrackedBuffer)
Format formats the node.
type Sql ¶
type Sql struct { RowsScanner sqlmap.RowsScanner `yaml:"-"` Name string `yaml:"name"` // SQL 名字,用于提示列表 Sql string `yaml:"sql"` // Format 格式化输出 // NONE 不输出 // JSON 使用 JSON 格式化输出 // TABLE 使用表格形式的格式化 // MARKDOWN 使用 MARKDOWN 格式化输出 Format string `yaml:"format"` // Iterations 表示 SQL 执行次数 Iterations int `yaml:"iterations"` AutoExecute bool `yaml:"autoExecute"` // 有名 SQL 是否自动执行,只有在 Name 有值时起作用 Disabled bool `yaml:"disabled"` IgnoreError bool `yaml:"ignoreError"` // SingleOne 只执行第一条 SQL SingleOne bool `yaml:"singleOne"` // contains filtered or unexported fields }
func (*Sql) Run ¶
func (c *Sql) Run(ds *DataSource, options *replOptions)
type TableRowsScanner ¶
type TableRowsScanner struct { Table table.Writer Format string Header []string Limit, Offset int RowVertical bool // contains filtered or unexported fields }
func NewTableRowsScanner ¶
func NewTableRowsScanner(format string, offset, limit int, rowVertical bool) *TableRowsScanner
func (*TableRowsScanner) AddRow ¶
func (t *TableRowsScanner) AddRow(rowIndex int, columns []any) bool
func (TableRowsScanner) Complete ¶
func (t TableRowsScanner) Complete()
func (*TableRowsScanner) StartExecute ¶
func (t *TableRowsScanner) StartExecute(string)
Click to show internal directories.
Click to hide internal directories.