Documentation
¶
Index ¶
- Constants
- func Exec(ctx context.Context, ex Executor, sql string, args ...any) error
- func IsDatabaseConnected(ctx context.Context, db *sql.DB) (perr error)
- func LoadDatabase(addr string, addrConnMax int) (drv string, db *sql.DB, err error)
- func ParseAddress(addr string) (drv, dsn string, err error)
- type DMLInsert
- type DMLLevel
- type Executor
- type Parsed
- type StatementType
- type TCLLevel
Constants ¶
View Source
const ( MySQLDialect = "mysql" MariaDBDialect = MySQLDialect PostgresDialect = "postgres" OracleDialect = "oracle" SQLServerDialect = "mssql" )
View Source
const ( StatementTypeTCLBegin = iota + StatementTypeTCL StatementTypeTCLEnd )
View Source
const ( StatementTypeDMLSingle = iota + StatementTypeDML StatementTypeDMLMultiple )
Variables ¶
This section is empty.
Functions ¶
func LoadDatabase ¶
func ParseAddress ¶
Types ¶
type Parsed ¶ added in v0.2.0
type Parsed interface {
// Origin returns the original SQL.
Origin() string
// Unknown returns true if not matched any languages.
Unknown() bool
// TCL returns the TCLLevel and true if the Origin is transaction control language.
TCL() (TCLLevel, bool)
// DCL returns true if the Origin is data control language.
DCL() bool
// DDL returns true if the Origin is data definition language.
DDL() bool
// DML returns the DMLLevel and true if the Origin is data manipulation language.
DML() (DMLLevel, bool)
// AsDMLInsert returns the structuring insert statement if possible.
AsDMLInsert() (DMLInsert, bool)
}
type StatementType ¶ added in v0.2.3
type StatementType = uint
const ( StatementTypeUnknown StatementType StatementTypeTCL StatementTypeDCL StatementTypeDDL StatementTypeDML )
func Preview ¶ added in v0.2.3
func Preview(sql string) StatementType
Preview analyzes the beginning of the query using a simpler and faster textual comparison to identify the statement type, borrows from the vitess.io/vitess/go/vt/sqlparser.
Click to show internal directories.
Click to hide internal directories.