Versions in this module Expand all Collapse all v1 v1.2.1 Sep 11, 2026 v1.2.0 Aug 27, 2026 v1.1.1 Aug 26, 2026 v1.1.0 Aug 26, 2026 v1.0.0 Aug 21, 2026 v0 v0.2.4 Sep 11, 2026 Changes in this version + var NewDBCliMgr = NewSqlMgr + func AutoMigrate(d def.DatabaseClient, model any, opts ...migrate.AutoMigrateOption) error + func ConvertToCountSQL(sqlStr string) string + func DetectSQLType(sql string) string + func EnsureDBExists(v *def.DBConnection) error + func FlushTableInfoCache() + func GetDBLogger() *cylog.Logger + func ParseCount(row map[string]any) int64 + func Q(options ...QueryOption) def.SQLStmt + func SplitSQLStatements(dbtype, sql string) []string + func ToColumn[T any](qr QueryResult, columnName string) ([]T, error) + func ToMigrationTableInfo(t def.TableInfo, opts ...migrate.ToMigrationTableInfoOption) def.TableInfo + func ToResultEx[T any](qr QueryResult, transform def.ItemTransformFunc, opts ...cystructmap.Option) (T, error) + func ToResult[T any](qr QueryResult, opts ...cystructmap.Option) (T, error) + func ToValue[T any](qr QueryResult, columnName string, rowIndex ...int) (T, error) + func WithTransactions[T IRepo](repos []T, fn func([]T) error) (err error) + type BooleanCondition = def.BooleanCondition + type CLiExtendProps struct + FormatTime string + NumbersAsString bool + type CLiExtendPropsFunc func(props *CLiExtendProps) + func WithNumbersAsString(asString bool) CLiExtendPropsFunc + func WithTimeFormat(format string) CLiExtendPropsFunc + type ColumnExpr = def.ColumnExpr + type ComparisonCondition = def.ComparisonCondition type DBCli + func (d *DBCli) AnalyzeSQL(sql string) (*def.SQLImpact, error) + func (d *DBCli) BatchInsertContext(ctx context.Context, tableName string, data []map[string]any, ...) (int64, error) + func (d *DBCli) BatchReplaceContext(ctx context.Context, tableName string, data []map[string]any, ...) (int64, error) + func (d *DBCli) BatchUpdateContext(ctx context.Context, tableName string, data []map[string]any, ...) (int64, error) + func (d *DBCli) BatchUpsert(tableName string, data []map[string]any, cc ...def.QueryOption) (int64, error) + func (d *DBCli) BatchUpsertContext(ctx context.Context, tableName string, data []map[string]any, ...) (int64, error) + func (d *DBCli) BeginTx() (r *DBCli, err error) + func (d *DBCli) BeginTxContext(ctx context.Context) (r *DBCli, err error) + func (d *DBCli) ColumnExists(tableName string, columnName string) (bool, error) + func (d *DBCli) CompatCollation() bool + func (d *DBCli) CountContext(ctx context.Context, tableName string, data map[string]any, ...) (int64, error) + func (d *DBCli) DBSubType() string + func (d *DBCli) DeleteContext(ctx context.Context, tableName string, data map[string]any, ...) (int64, error) + func (d *DBCli) DirectExcute(sql string, arguments ...any) (int64, error) + func (d *DBCli) DirectExecute(sql string, arguments ...any) (int64, error) + func (d *DBCli) DirectExecuteContext(ctx context.Context, sql string, arguments ...any) (int64, error) + func (d *DBCli) DirectForEachQuery(tableName string, selectSQL string, fn func(RowData) error) error + func (d *DBCli) DirectForEachQueryContext(ctx context.Context, tableName string, selectSQL string, ...) error + func (d *DBCli) DirectNQuery(sql string, data any) ([]map[string]any, error) + func (d *DBCli) DirectNQueryContext(ctx context.Context, sql string, data any) ([]map[string]any, error) + func (d *DBCli) DirectNQueryRow(sql string, data any) (map[string]any, error) + func (d *DBCli) DirectNQueryRowContext(ctx context.Context, sql string, data any) (map[string]any, error) + func (d *DBCli) DirectNamedExecute(sql string, data any) (int64, error) + func (d *DBCli) DirectNamedExecuteContext(ctx context.Context, sql string, data any) (int64, error) + func (d *DBCli) DirectNamedForEachQuery(tableName string, selectSQL string, data any, fn func(RowData) error) error + func (d *DBCli) DirectNamedForEachQueryContext(ctx context.Context, tableName string, selectSQL string, data any, ...) error + func (d *DBCli) DirectNamedInsert(sql string, data any) (int64, error) + func (d *DBCli) DirectNamedInsertContext(ctx context.Context, sql string, data any) (int64, error) + func (d *DBCli) DirectNamedQuery(sql string, data any) ([]map[string]any, error) + func (d *DBCli) DirectNamedQueryAsResult(sql string, params any) def.QueryResult + func (d *DBCli) DirectNamedQueryAsResultContext(ctx context.Context, sql string, params any) def.QueryResult + func (d *DBCli) DirectNamedQueryContext(ctx context.Context, sql string, data any) ([]map[string]any, error) + func (d *DBCli) DirectNamedQueryFast(sql string, data any) ([][]any, []string, error) + func (d *DBCli) DirectNamedQueryFastContext(ctx context.Context, sql string, data any) ([][]any, []string, error) + func (d *DBCli) DirectNamedQueryRow(sql string, data any) (map[string]any, error) + func (d *DBCli) DirectNamedQueryRowContext(ctx context.Context, sql string, data any) (map[string]any, error) + func (d *DBCli) DirectNamedQueryRowFast(sql string, data any) ([]any, []string, error) + func (d *DBCli) DirectNamedQueryRowFastContext(ctx context.Context, sql string, data any) ([]any, []string, error) + func (d *DBCli) DirectNamedSelect(dest any, query string, arg any) error + func (d *DBCli) DirectQuery(sql string, arguments ...any) ([]map[string]any, error) + func (d *DBCli) DirectQueryContext(ctx context.Context, sql string, arguments ...any) ([]map[string]any, error) + func (d *DBCli) DirectQueryFast(sql string, arguments ...any) ([][]any, []string, error) + func (d *DBCli) DirectQueryFastContext(ctx context.Context, sql string, arguments ...any) ([][]any, []string, error) + func (d *DBCli) DirectQueryRow(sql string, args ...any) (map[string]any, error) + func (d *DBCli) DirectQueryRowContext(ctx context.Context, sql string, args ...any) (map[string]any, error) + func (d *DBCli) DirectQueryRowFast(sql string, args ...any) ([]any, []string, error) + func (d *DBCli) DirectQueryRowFastContext(ctx context.Context, sql string, args ...any) ([]any, []string, error) + func (d *DBCli) EnsureDBExists(dbName string) error + func (d *DBCli) EnsureLimit(sql string, limit, offset int) (string, error) + func (d *DBCli) Execute(sql string, arguments ...any) (int64, error) + func (d *DBCli) ExecuteContext(ctx context.Context, sql string, arguments ...any) (int64, error) + func (d *DBCli) ExistsContext(ctx context.Context, tableName string, data map[string]any, ...) (bool, error) + func (d *DBCli) ExplainSQL(sql string) def.QueryResult + func (d *DBCli) FirstAsResult(tableName any, data map[string]any, cc ...QueryOption) QueryResult + func (d *DBCli) FirstAsResultContext(ctx context.Context, tableName any, data map[string]any, cc ...QueryOption) QueryResult + func (d *DBCli) FirstContext(ctx context.Context, tableName string, data map[string]any, ...) (map[string]any, error) + func (d *DBCli) ForEachData(tableName string, data []map[string]any, fn func(RowData) error) error + func (d *DBCli) ForEachQuery(tableName string, selectSQL string, fn func(RowData) error) error + func (d *DBCli) ForEachQueryByWhere(tableName string, where []def.QueryOption, p P, fn func(RowData) error) error + func (d *DBCli) ForEachQueryContext(ctx context.Context, tableName string, selectSQL string, ...) error + func (d *DBCli) GetContext(ctx context.Context, dest any, query string, args ...any) error + func (d *DBCli) GetDatabases() ([]string, error) + func (d *DBCli) GetIndexes(tableName string) ([]dialect.IndexInfo, error) + func (d *DBCli) GetObjects(dbName string, schema *string, objectType dialect.DatabaseObjectType) ([]string, error) + func (d *DBCli) GetPassword() string + func (d *DBCli) GetPrimaryKeys(tableName string) ([]string, error) + func (d *DBCli) GetSchemaObjects(dbName, schema string) (*dialect.SchemaObjects, error) + func (d *DBCli) GetSchemaSummaries(dbName string) ([]dialect.SchemaSummary, error) + func (d *DBCli) GetSchemas(dbName string) ([]string, error) + func (d *DBCli) GetSqlTransformer() (DatabaseTransformer, bool) + func (d *DBCli) GetTableInfo(tableName string) (TableInfo, error) + func (d *DBCli) GetTables(dbName string, schema *string, keyword *string) ([]string, error) + func (d *DBCli) GetUniqueKeys(tableName string) ([]string, error) + func (d *DBCli) GetWriteCapability() dialect.WriteCapability + func (d *DBCli) InsertAndGetID(tableName string, data map[string]any, cc ...def.QueryOption) (int64, error) + func (d *DBCli) InsertAndGetIDContext(ctx context.Context, tableName string, data map[string]any, ...) (int64, error) + func (d *DBCli) InsertContext(ctx context.Context, tableName string, data map[string]any, ...) (int64, error) + func (d *DBCli) ListAsResult(tableName any, data map[string]any, cc ...QueryOption) QueryResult + func (d *DBCli) ListAsResultContext(ctx context.Context, tableName any, data map[string]any, cc ...QueryOption) QueryResult + func (d *DBCli) ListContext(ctx context.Context, tableName string, data map[string]any, ...) ([]map[string]any, error) + func (d *DBCli) ListWithPageAsResult(tableName any, data map[string]any, pageIndex int, pageSize int, ...) QueryResult + func (d *DBCli) ListWithPageAsResultContext(ctx context.Context, tableName any, data map[string]any, pageIndex int, ...) QueryResult + func (d *DBCli) ListWithPageContext(ctx context.Context, tableName string, data map[string]any, pageIndex int, ...) ([]map[string]any, int64, error) + func (d *DBCli) NQueryContext(ctx context.Context, sql string, data any) ([]map[string]any, error) + func (d *DBCli) NQueryRow(sql string, data any) (map[string]any, error) + func (d *DBCli) NQueryRowContext(ctx context.Context, sql string, data any) (map[string]any, error) + func (d *DBCli) NamedExecute(sql string, data any) (int64, error) + func (d *DBCli) NamedExecuteContext(ctx context.Context, sql string, data any) (int64, error) + func (d *DBCli) NamedForEachQuery(tableName string, selectSQL string, data any, fn func(RowData) error) error + func (d *DBCli) NamedForEachQueryContext(ctx context.Context, tableName string, selectSQL string, data any, ...) error + func (d *DBCli) NamedQuery(sql string, data any) ([]map[string]any, error) + func (d *DBCli) NamedQueryAsResult(sql string, data any) QueryResult + func (d *DBCli) NamedQueryAsResultContext(ctx context.Context, sql string, data any) QueryResult + func (d *DBCli) NamedQueryContext(ctx context.Context, sql string, data any) ([]map[string]any, error) + func (d *DBCli) NamedQueryFastContext(ctx context.Context, sql string, data any) ([][]any, []string, error) + func (d *DBCli) NamedQueryRow(sql string, data any) (map[string]any, error) + func (d *DBCli) NamedQueryRowAsResultContext(ctx context.Context, sql string, data any) QueryResult + func (d *DBCli) NamedQueryRowContext(ctx context.Context, sql string, data any) (map[string]any, error) + func (d *DBCli) NamedQueryRowFast(sql string, data any) ([]any, []string, error) + func (d *DBCli) NamedQueryRowFastContext(ctx context.Context, sql string, data any) ([]any, []string, error) + func (d *DBCli) ObjectExists(objectName string, objectType dialect.DatabaseObjectType) (bool, error) + func (d *DBCli) PaginatedList(tableName string, data map[string]any, pageIndex int, pageSize int, ...) ([]map[string]any, int64, error) + func (d *DBCli) PaginatedListAsResult(tableName any, data map[string]any, pageIndex int, pageSize int, ...) QueryResult + func (d *DBCli) PaginatedListAsResultContext(ctx context.Context, tableName any, data map[string]any, pageIndex int, ...) QueryResult + func (d *DBCli) PaginatedListContext(ctx context.Context, tableName string, data map[string]any, pageIndex int, ...) ([]map[string]any, int64, error) + func (d *DBCli) PinSingleConnection() *DBCli + func (d *DBCli) QueryAsResult(sql string, arguments ...any) QueryResult + func (d *DBCli) QueryAsResultContext(ctx context.Context, sql string, arguments ...any) QueryResult + func (d *DBCli) QueryContext(ctx context.Context, sql string, arguments ...any) ([]map[string]any, error) + func (d *DBCli) QueryFast(sql string, arguments ...any) ([][]any, []string, error) + func (d *DBCli) QueryFastContext(ctx context.Context, sql string, arguments ...any) ([][]any, []string, error) + func (d *DBCli) QueryRow(sql string, args ...any) (map[string]any, error) + func (d *DBCli) QueryRowAsResult(sql string, args ...any) QueryResult + func (d *DBCli) QueryRowAsResultContext(ctx context.Context, sql string, args ...any) QueryResult + func (d *DBCli) QueryRowContext(ctx context.Context, sql string, args ...any) (map[string]any, error) + func (d *DBCli) QueryRowFast(sql string, args ...any) ([]any, []string, error) + func (d *DBCli) QueryRowFastContext(ctx context.Context, sql string, args ...any) ([]any, []string, error) + func (d *DBCli) QueryWithLimitContext(ctx context.Context, sql string, limit, offset int) ([][]any, []string, error) + func (d *DBCli) ReplaceContext(ctx context.Context, tableName string, data map[string]any, ...) (int64, error) + func (d *DBCli) ResumeConstraintChecks() (string, error) + func (d *DBCli) SelectContext(ctx context.Context, dest any, query string, args ...any) error + func (d *DBCli) SuspendConstraintChecks() (string, error) + func (d *DBCli) UnpinSingleConnection() + func (d *DBCli) UpdateContext(ctx context.Context, tableName string, data map[string]any, ...) (int64, error) + func (d *DBCli) UpsertContext(ctx context.Context, tableName string, data map[string]any, ...) (int64, error) + func (d *DBCli) ValidateSQL(sql string) *def.ValidationError + func (d *DBCli) WithTransactionContext(ctx context.Context, fn func(tx DatabaseClient) error) (err error) type DBMgr + func (s *DBMgr) Exist(key string) bool + func (s *DBMgr) GetDatebase() []string + func (s *DBMgr) SetCliIfNotExists(key string, cli *DBCli) + func (s *DBMgr) TestConnect(con *def.DBConnection) error + type DatabaseObjectType = dialect.DatabaseObjectType + const ObjectTypeFunction + const ObjectTypeProcedure + const ObjectTypeSequence + const ObjectTypeTable + const ObjectTypeTrigger + const ObjectTypeView type Expression + func Named(name string) Expression type IRepo + NewTransactionCopy func(tx *DBCli) (IRepo, error) + type ItemTransformFunc = def.ItemTransformFunc type OP + const OP_NOT_LIKE + type Object = map[string]any + type P = map[string]any + type PaginatedResult = schema.PaginatedResult[T] + func ToPagedResultEx[T any](qr QueryResult, transform ItemTransformFunc, opts ...cystructmap.Option) (*PaginatedResult[T], error) + func ToPagedResult[T any](qr QueryResult, opts ...cystructmap.Option) (*PaginatedResult[T], error) + type QueryOption = def.QueryOption + func WithBeforeBuild(callback func(def.SQLStmt) error) QueryOption + func WithContains(field string, value string) QueryOption + func WithEQs(field ...string) QueryOption + func WithEndsWith(field string, value string) QueryOption + func WithGTEs(field ...string) QueryOption + func WithGTs(field ...string) QueryOption + func WithISNOTNULL(field string) QueryOption + func WithISNULL(field string) QueryOption + func WithInSub(field string, subquery def.SQLStmt) QueryOption + func WithLTEs(field ...string) QueryOption + func WithLTs(field ...string) QueryOption + func WithNEQs(field ...string) QueryOption + func WithNotInSub(field string, subquery def.SQLStmt) QueryOption + func WithOrderByAsc(orders ...any) QueryOption + func WithOrderByDesc(orders ...any) QueryOption + func WithStartsWith(field string, value string) QueryOption + func WithUnion(stmt *ss.SQLStmt) QueryOption + func WithUnionAll(stmt *ss.SQLStmt) QueryOption + type QueryResult = def.QueryResult + type RawCondition = def.RawCondition + type SQLBlock = dialect.SQLBlock + type SQLImpact = def.SQLImpact + type SQLStmt = def.SQLStmt + type SortDirection = ss.SortDirection + const SortAsc + const SortDesc + type TableInfo = def.TableInfo + type ValidationError = def.ValidationError type Where + func AllEQ(fields []string, values ...any) Where + func AllGT(fields []string, values ...any) Where + func AllGTE(fields []string, values ...any) Where + func AllLT(fields []string, values ...any) Where + func AllLTE(fields []string, values ...any) Where + func AllNEQ(fields []string, values ...any) Where + func AnyEQ(fields []string, values ...any) Where + func AnyGT(fields []string, values ...any) Where + func AnyGTE(fields []string, values ...any) Where + func AnyLT(fields []string, values ...any) Where + func AnyLTE(fields []string, values ...any) Where + func AnyNEQ(fields []string, values ...any) Where + func ISNOTNULL(field string) Where + func ISNULL(field string) Where + func LIKEN(field string, value string) Where + func NOT_LIKE(field string, value string, pt def.LikePatternType) Where + func NOT_LIKEC(field string, value string) Where + func NOT_LIKEL(field string, value string) Where + func NOT_LIKEN(field string, value string) Where + func NOT_LIKER(field string, value string) Where + func TupleEQ(cols []string, vals ...any) Where + func TupleGT(cols []string, vals ...any) Where + func TupleGTE(cols []string, vals ...any) Where + func TupleIN(cols []string, valsList [][]any) Where + func TupleLT(cols []string, vals ...any) Where + func TupleLTE(cols []string, vals ...any) Where + func TupleNE(cols []string, vals ...any) Where + func TupleNOTIN(cols []string, valsList [][]any) Where v0.0.1 Sep 23, 2025 Changes in this version + const DefaultBufferSize + const ErrCodeConnection + const ErrCodeConstraint + const ErrCodeDuplicate + const ErrCodeInvalidParam + const ErrCodeNotFound + const ErrCodeQuery + const ErrCodeTimeout + const ErrCodeTransaction + const ErrCodeUnsupported + const MigrationCommentPrefix + const MigrationDown + const MigrationUp + const PreRetTypeCallCallback + const PreRetTypeContinue + const PreRetTypeReturn + var WithValue = WithLiteral + func DBLog() *cylog.Logger + func EscapeLikePattern(pattern string, t LikePatternType) string + func FormatValue(v interface{}, colType DBFieldType) (string, error) + func GetDBAndTable(cli DatabaseClient, name ...string) (string, string) + func GetSupportSqlDialect() []string + func InMapParam(ids map[string]struct{}) string + func InParam(ids []string) string + func InParam2(ids [][]string) string + func InternalExcute(cli DatabaseClient, sql string, arguments ...interface{}) (int64, error) + func InternalNQuery(cli DatabaseClient, sql string, data interface{}) ([]map[string]interface{}, error) + func InternalNQueryOne(cli DatabaseClient, sql string, data interface{}) (map[string]interface{}, error) + func InternalQuery(cli DatabaseClient, sql string, arguments ...interface{}) ([]map[string]interface{}, error) + func InternalQueryOne(cli DatabaseClient, sql string, arguments ...interface{}) (map[string]interface{}, error) + func IsMySQLKeyword(word string) bool + func LeafDirs(efs *embed.FS) ([]string, error) + func NewSQLParseError(errorType, message string, lineNum int, lineText string) error + func NormalData(d interface{}) interface + func NormalData2(d interface{}) interface + func ReadSQLFile(r io.Reader, callback FuncSQLStatementCallback, ...) error + func RegisterSqlDialect(dbtype string, sql any) + func TestParseMySQL() + func WithBufferSize(size int) func(*ReadSQLFileOptions) + func WithFilter(filter []string) func(*ReadSQLFileOptions) + func WithMigrationMode(mode string) func(*ReadSQLFileOptions) + func WithPreProcessSqlLine(callback FuncPreProcessSqlLine) func(*ReadSQLFileOptions) + func WithTransaction[T IRepo](repo T, fn func(repo T) error) error + func WithWordCallback(callback ProcessWordCallback) func(*ReadSQLFileOptions) + type ArithExpr struct + Alias string + Left Expression + Op string + Right Expression + func (ae *ArithExpr) GetAlias() string + func (ae *ArithExpr) GetFields() []string + func (ae *ArithExpr) SetAlias(alias string) Expression + func (ae *ArithExpr) ToSQL(dt DatabaseTransformer) (string, error) + type BuildResult struct + ParamOrder []string + SQL string + type BuildSql interface + GetAssignString func(dt DatabaseTransformer, all bool) (string, []string, error) + GetFieldsString func(dt DatabaseTransformer, skipAS bool) (string, error) + GetPkFieldsString func(dt DatabaseTransformer, skipAS bool) (string, error) + GetValuesString func(dt DatabaseTransformer, all bool) (string, []string, error) + type CRUDOperations interface + BatchInsert func(ctx context.Context, tableName string, data []map[string]any) (int64, error) + Delete func(ctx context.Context, tableName string, condition map[string]any) (int64, error) + Insert func(ctx context.Context, tableName string, data map[string]any) (int64, error) + Replace func(ctx context.Context, tableName string, data map[string]any) (int64, error) + Update func(ctx context.Context, tableName string, data map[string]any, ...) (int64, error) + type CRUDSqlFuncName string + const FuncNameGetDeleteSql + const FuncNameGetInsertSql + const FuncNameGetReplaceSql + const FuncNameGetSelectSql + const FuncNameGetUpdateSql + type CaseExpr struct + Alias string + ElseClause Expression + Value Expression + WhenClauses []WhenThenClause + func (ce *CaseExpr) ELSE(elseClause Expression) Expression + func (ce *CaseExpr) GetFields() []string + func (ce *CaseExpr) SetAlias(alias string) Expression + func (ce *CaseExpr) ToSQL(dt DatabaseTransformer) (string, error) + type Condition struct + Condition string + Fields []string + type Config struct + Connections []DBConnection + type DBCli struct + func NewDBCli(cli IDBOperWrapper, dbtype, key, database, un, pw string) *DBCli + func TryConnect(v *DBConnection) (*DBCli, error) + func (d *DBCli) BatchInsert(tableName string, data []map[string]interface{}, cc ...FuncWithBuilder) (int64, error) + func (d *DBCli) BatchReplace(tableName string, data []map[string]interface{}, cc ...FuncWithBuilder) (int64, error) + func (d *DBCli) BatchUpdate(tableName string, data []map[string]interface{}, cc ...FuncWithBuilder) (int64, error) + func (d *DBCli) BeginX() (r *DBCli, err error) + func (d *DBCli) Close() error + func (d *DBCli) Commit() error + func (d *DBCli) Count(tableName any, data map[string]interface{}, cc ...FuncWithBuilder) (int64, error) + func (d *DBCli) DBType() string + func (d *DBCli) Database() string + func (d *DBCli) Delete(tableName any, data map[string]interface{}, cc ...FuncWithBuilder) (int64, error) + func (d *DBCli) Excute(sql string, arguments ...interface{}) (int64, error) + func (d *DBCli) Exists(tableName string, data map[string]interface{}, cc ...FuncWithBuilder) (bool, error) + func (d *DBCli) FieldExists(tableName string, fieldName string) (bool, error) + func (d *DBCli) First(tableName any, data map[string]interface{}, cc ...FuncWithBuilder) (map[string]interface{}, error) + func (d *DBCli) Get(dest interface{}, query string, args ...interface{}) error + func (d *DBCli) GetDB() *sqlx.DB + func (d *DBCli) GetDDLSql(funcName DDLSqlFuncName, name ...string) (*SqlContent, error) + func (d *DBCli) GetPK(tableName string) ([]string, error) + func (d *DBCli) GetSortedSql(funcName SortFuncName, database string, names []string) ([]*SqlContent, error) + func (d *DBCli) GetTableColumns(tableName string) ([]*DBColumn, error) + func (d *DBCli) Insert(tableName string, data map[string]interface{}, cc ...FuncWithBuilder) (int64, error) + func (d *DBCli) IsTableExist(tableName string) (bool, error) + func (d *DBCli) Key() string + func (d *DBCli) List(tableName any, data map[string]interface{}, cc ...FuncWithBuilder) ([]map[string]interface{}, error) + func (d *DBCli) ListWithPage(tableName any, data map[string]interface{}, pageIndex int, pageSize int, ...) ([]map[string]interface{}, int, error) + func (d *DBCli) MakeSureDBExists(dbName string) error + func (d *DBCli) NExcute(sql string, data interface{}) (int64, error) + func (d *DBCli) NQuery(sql string, data interface{}) ([]map[string]interface{}, error) + func (d *DBCli) NQueryOne(sql string, data interface{}) (map[string]interface{}, error) + func (d *DBCli) PW() string + func (d *DBCli) Query(sql string, arguments ...interface{}) ([]map[string]interface{}, error) + func (d *DBCli) QueryOne(sql string, args ...interface{}) (map[string]interface{}, error) + func (d *DBCli) ReadSQLFile(r io.Reader, callback FuncSQLStatementCallback, ...) error + func (d *DBCli) Replace(tableName string, data map[string]interface{}, cc ...FuncWithBuilder) (int64, error) + func (d *DBCli) Rollback() error + func (d *DBCli) Select(dest interface{}, query string, args ...interface{}) error + func (d *DBCli) TravelData(tableName string, data []map[string]interface{}, ...) error + func (d *DBCli) TravelQuery(tableName string, selectSQL string, fn func(*DBCli, *RowData) error) error + func (d *DBCli) Update(tableName string, data map[string]interface{}, cc ...FuncWithBuilder) (int64, error) + func (d *DBCli) Upsert(tableName string, data map[string]interface{}, cc ...FuncWithBuilder) (int64, error) + func (d *DBCli) WithTransaction(fn func(tx *DBCli) error) (err error) + type DBColumn struct + ColumnKey string + DBFieldType DBFieldType + Name string + Nullable bool + OrgDataType string + type DBConnection struct + DBName string + Host string + Key string + Path string + Port int + Pw string + Role string + SSLMode string + Schema string + Service string + Type string + Un string + type DBFieldType int + const DBFieldTypeBinary + const DBFieldTypeBit + const DBFieldTypeFloat + const DBFieldTypeInt + const DBFieldTypeJson + const DBFieldTypeString + const DBFieldTypeTime + type DBMgr struct + func NewSqlMgr(conf *Config, migrateFileFunc ...MigrateFileFunc) (*DBMgr, error) + func (s *DBMgr) CloseAll() + func (s *DBMgr) GetCli(key string) *DBCli + func (s *DBMgr) GetOrCreateCli(params map[string]interface{}) (*DBCli, error) + func (s *DBMgr) InitByConfig(conf *Config) error + func (s *DBMgr) SetCli(key string, cli *DBCli) + type DDLSqlFunc func(cli DatabaseClient, name ...string) (*SqlContent, error) + type DDLSqlFuncName string + const FuncNameGetBeginSql + const FuncNameGetCreateFunctionSql + const FuncNameGetCreateProcedureSql + const FuncNameGetCreateTableSql + const FuncNameGetCreateViewSql + const FuncNameGetEndSql + const FuncNameGetTableEventSql + type DatabaseClient interface + Close func() error + DBType func() string + Database func() string + Excute func(sql string, arguments ...interface{}) (int64, error) + Get func(dest interface{}, query string, args ...interface{}) error + NQuery func(sql string, data any) ([]map[string]any, error) + NQueryOne func(sql string, data any) (map[string]any, error) + PW func() string + Query func(sql string, args ...interface{}) ([]map[string]interface{}, error) + Select func(dest interface{}, query string, args ...interface{}) error + type DatabaseError struct + Cause error + Code string + Details string + Message string + func NewDatabaseError(code, message string) *DatabaseError + func (e *DatabaseError) Error() string + func (e *DatabaseError) Unwrap() error + func (e *DatabaseError) WithCause(cause error) *DatabaseError + func (e *DatabaseError) WithDetails(details string) *DatabaseError + type DatabaseManager interface + AddClient func(key string, client DatabaseClient) + CloseAll func() error + GetClient func(key string) (DatabaseClient, error) + ListClients func() []string + RemoveClient func(key string) + type DatabaseMetadata interface + Name func() string + Type func() string + Version func(ctx context.Context) (string, error) + type DatabaseTransformer interface + BuildPagination func(limit, offset string) string + BuildReplaceSQL func(tableName string, buildSql BuildSql) (string, []string, error) + BuildUpsertSQL func(tableName string, buildSql BuildSql) (string, []string, error) + EscapeColumnName func(columnName string) string + EscapeTableName func(tableName string) string + SupportsBatch func() bool + func GetSqlTransformer(dbtype string) (DatabaseTransformer, bool) + type DefaultDBFieldType int + const DefaultDBFieldTypeBinary + const DefaultDBFieldTypeBit + const DefaultDBFieldTypeBool + const DefaultDBFieldTypeFloat + const DefaultDBFieldTypeInt + const DefaultDBFieldTypeJson + const DefaultDBFieldTypeString + const DefaultDBFieldTypeTime + type Expression interface + GetFields func() []string + SetAlias func(alias string) Expression + ToSQL func(dt DatabaseTransformer) (string, error) + func ADD(left, right Expression) Expression + func AS(v ...string) Expression + func AVG(arg Expression) Expression + func CASE(value Expression, whenThenPairs ...Expression) Expression + func CASE_WHEN(whenThenPairs ...Expression) Expression + func COALESCE(args ...Expression) Expression + func CONCAT(args ...Expression) Expression + func CONST(value any) Expression + func COUNT(arg Expression) Expression + func COUNT_DISTINCT(arg Expression) Expression + func DIV(left, right Expression) Expression + func FIELD(name string) Expression + func FUNC(name string, args ...Expression) Expression + func FUNC_DISTINCT(name string, args ...Expression) Expression + func IFNULL(arg1, arg2 Expression) Expression + func MAX(arg Expression) Expression + func MIN(arg Expression) Expression + func MOD(left, right Expression) Expression + func MUL(left, right Expression) Expression + func SUB(left, right Expression) Expression + func SUM(arg Expression) Expression + type ExtraData interface + IsBlockEnd func(string) bool + type FieldData struct + Data interface{} + Index int + IsPK bool + IsUQ bool + Name string + Nullable bool + OrgDataType string + Type DBFieldType + type FuncExpr struct + Alias string + Args []Expression + Distinct bool + Name string + func (fe *FuncExpr) GetAlias() string + func (fe *FuncExpr) GetFields() []string + func (fe *FuncExpr) SetAlias(alias string) Expression + func (fe *FuncExpr) ToSQL(dt DatabaseTransformer) (string, error) + type FuncPreProcessSqlLine func(ctx *ParseContext, pline *string) (PreRetType, error) + type FuncSQLStatementCallback func(sqlStatement *SQLStatement) error + type FuncWithBuilder func(SQLBuilder) SQLBuilder + func WithBetween(field string, start, end any) FuncWithBuilder + func WithCount(field string) FuncWithBuilder + func WithDatabase(database string) FuncWithBuilder + func WithDistinct(distinct bool) FuncWithBuilder + func WithEQ(field ...string) FuncWithBuilder + func WithFields(fields any, reset ...bool) FuncWithBuilder + func WithGT(field ...string) FuncWithBuilder + func WithGTE(field ...string) FuncWithBuilder + func WithGroupBy(columns any) FuncWithBuilder + func WithIn(field string, values []any) FuncWithBuilder + func WithInnerJoin(tableSrc TableSource, on ...Where) FuncWithBuilder + func WithJoin(tableSrc TableSource, on ...Where) FuncWithBuilder + func WithLT(field ...string) FuncWithBuilder + func WithLTE(field ...string) FuncWithBuilder + func WithLeftJoin(tableSrc TableSource, on ...Where) FuncWithBuilder + func WithLike(field string, value string) FuncWithBuilder + func WithLikeL(field string, value string) FuncWithBuilder + func WithLikeR(field string, value string) FuncWithBuilder + func WithLimit(limit int) FuncWithBuilder + func WithNEQ(field ...string) FuncWithBuilder + func WithNotIn(field string, values []any) FuncWithBuilder + func WithOffset(offset int) FuncWithBuilder + func WithOrderBy(orderBy ...OrderBy) FuncWithBuilder + func WithRightJoin(tableSrc TableSource, on ...Where) FuncWithBuilder + func WithSelect(selects any) FuncWithBuilder + func WithSubQueryValues(builder SQLBuilder) FuncWithBuilder + func WithTable(table any) FuncWithBuilder + func WithUpdate(columns any) FuncWithBuilder + func WithUpdateExpr(updates ...Expression) FuncWithBuilder + func WithValues(data ...[]Expression) FuncWithBuilder + func WithValuesAppend(data ...[]Expression) FuncWithBuilder + func WithWhere(where ...Where) FuncWithBuilder + func WithWhereAnd(where ...Where) FuncWithBuilder + func WithWhereOr(where ...Where) FuncWithBuilder + type IDBOperWrapper interface + BindNamed func(query string, arg interface{}) (string, []interface{}, error) + Exec func(query string, args ...any) (sql.Result, error) + ExecContext func(ctx context.Context, query string, args ...any) (sql.Result, error) + Get func(dest interface{}, query string, args ...interface{}) error + GetContext func(ctx context.Context, dest interface{}, query string, args ...interface{}) error + MustExec func(query string, args ...interface{}) sql.Result + MustExecContext func(ctx context.Context, query string, args ...interface{}) sql.Result + NamedExec func(query string, arg interface{}) (sql.Result, error) + NamedExecContext func(ctx context.Context, query string, arg interface{}) (sql.Result, error) + NamedQuery func(query string, arg interface{}) (*sqlx.Rows, error) + Prepare func(query string) (*sql.Stmt, error) + PrepareContext func(ctx context.Context, query string) (*sql.Stmt, error) + PrepareNamed func(query string) (*sqlx.NamedStmt, error) + PrepareNamedContext func(ctx context.Context, query string) (*sqlx.NamedStmt, error) + Preparex func(query string) (*sqlx.Stmt, error) + PreparexContext func(ctx context.Context, query string) (*sqlx.Stmt, error) + Query func(query string, args ...any) (*sql.Rows, error) + QueryContext func(ctx context.Context, query string, args ...any) (*sql.Rows, error) + QueryRow func(query string, args ...any) *sql.Row + QueryRowContext func(ctx context.Context, query string, args ...any) *sql.Row + QueryRowx func(query string, args ...interface{}) *sqlx.Row + QueryRowxContext func(ctx context.Context, query string, args ...interface{}) *sqlx.Row + Queryx func(query string, args ...interface{}) (*sqlx.Rows, error) + QueryxContext func(ctx context.Context, query string, args ...interface{}) (*sqlx.Rows, error) + Select func(dest interface{}, query string, args ...interface{}) error + SelectContext func(ctx context.Context, dest interface{}, query string, args ...interface{}) error + type IRepo interface + GetDBCli func() *DBCli + SetDBCli func(*DBCli) + type LikePatternType int + const Contains + const EndsWith + const Escape + const None + const StartsWith + type LiteralValue struct + Embed bool + Fields []string + Value any + func (lv *LiteralValue) GetFields() []string + func (lv *LiteralValue) GetValue() (string, error) + func (lv *LiteralValue) SetAlias(alias string) Expression + func (lv *LiteralValue) ToSQL(dt DatabaseTransformer) (string, error) + type MigrateFileFunc func(pm *MigrateSQLParam) *MigrateSQLParam + func WithIgnoreError(ignoreError bool) MigrateFileFunc + func WithMigrateFileFunc(f *embed.FS) MigrateFileFunc + func WithServiceOwner(serviceOwner string) MigrateFileFunc + type MigrateInfo struct + DBType string + Key string + type MigrateSQLParam struct + type OP string + const OP_ADD + const OP_BETWEEN + const OP_DIVIDE + const OP_EQ + const OP_EXISTS + const OP_GT + const OP_GTE + const OP_IN + const OP_IS_NOT_NULL + const OP_IS_NULL + const OP_LIKE + const OP_LT + const OP_LTE + const OP_MOD + const OP_MULTIPLY + const OP_NEQ + const OP_NOT_EXISTS + const OP_NOT_IN + const OP_SUBTRACT + type OrderBy struct + Column []Expression + Direction string + func ASC(field any) OrderBy + func DESC(field any) OrderBy + type PARAMS = map[string]interface + type ParameterValue struct + Name string + func (pv *ParameterValue) GetFields() []string + func (pv *ParameterValue) GetValue() (string, error) + func (pv *ParameterValue) SetAlias(alias string) Expression + func (pv *ParameterValue) ToSQL(dt DatabaseTransformer) (string, error) + type ParseContext struct + BlockIndex int + CurrentLineNum int + CurrentStmt strings.Builder + CurrentType SQLType + ExpectedStringEnd string + Extra ExtraData + Filter []string + HasContent bool + IsMultiLineComment bool + LineContent string + PreProcessSqlLine FuncPreProcessSqlLine + StartLineNum int + TraceWord *TraceWord + TypeWord string + WordCallback ProcessWordCallback + func (ctx *ParseContext) ReadSQLCallback(callback FuncSQLStatementCallback) error + func (pc *ParseContext) IsBlockEnd(line string) bool + func (pc *ParseContext) IsCurrentTypeNull() bool + func (pc *ParseContext) Reset() + type ParseMysqlContext struct + func (ctx *ParseMysqlContext) GetParamExpr(index int) *ParameterValue + func (ctx *ParseMysqlContext) GetParamValue(index int) string + type PreRetType int + type ProcessWordCallback func(ctx *ParseContext, word *cyutil.WordInfo) (bool, error) + type QueryExecutor interface + Exec func(ctx context.Context, sql string, args ...any) (sql.Result, error) + Query func(ctx context.Context, sql string, args ...any) ([]map[string]any, error) + QueryRow func(ctx context.Context, sql string, args ...any) (map[string]any, error) + type QueryMetadata struct + ExecutionTime time.Duration + QueryHash string + RowsAffected int64 + type ReadSQLFileOptions struct + BufferSize int + Filter []string + MigrationMode string + PreProcessSqlLine FuncPreProcessSqlLine + WordCallback ProcessWordCallback + func NewReadSQLFileOptions(options ...func(*ReadSQLFileOptions)) ReadSQLFileOptions + type ResultSet struct + Data []T + Metadata QueryMetadata + Page int + PageSize int + TotalCount int64 + type RowData struct + Data []*FieldData + func (r *RowData) GetData() map[string]interface{} + func (r *RowData) GetReplaceSql(cli DatabaseClient, table string) (string, error) + type SQLBuilder interface + Build func(dt DatabaseTransformer) (*BuildResult, error) + Count func(fields string) SQLBuilder + Database func(db string) SQLBuilder + Distinct func(distinct bool) SQLBuilder + Fields func(columns any, reset ...bool) SQLBuilder + From func(tableSrc any) SQLBuilder + GroupBy func(columns any) SQLBuilder + Having func(fv Where) SQLBuilder + HavingAnd func(fvs ...Where) SQLBuilder + HavingOr func(fvs ...Where) SQLBuilder + InnerJoin func(tableSrc TableSource, condition ...Where) SQLBuilder + Join func(tableSrc TableSource, condition ...Where) SQLBuilder + LeftJoin func(tableSrc TableSource, condition ...Where) SQLBuilder + Limit func(limit int) SQLBuilder + LimitPlaceholder func(limit string) SQLBuilder + Offset func(offset int) SQLBuilder + OffsetPlaceholder func(offset string) SQLBuilder + OrderBy func(orderBy ...OrderBy) SQLBuilder + PrimaryKeys func(keys ...string) SQLBuilder + RightJoin func(tableSrc TableSource, condition ...Where) SQLBuilder + Select func(fields any) SQLBuilder + SubQueryValues func(builder SQLBuilder) SQLBuilder + Table func(table any) SQLBuilder + Type func(t SQLOperationType) SQLBuilder + Update func(columns any) SQLBuilder + UpdateExpr func(updates ...Expression) SQLBuilder + Values func(data ...[]Expression) SQLBuilder + ValuesAppend func(data ...[]Expression) SQLBuilder + Where func(fv Where, reset ...bool) SQLBuilder + WhereAnd func(fvs ...Where) SQLBuilder + WhereOr func(fvs ...Where) SQLBuilder + func Builder() SQLBuilder + func ParseMySQL(sql string) (SQLBuilder, error) + type SQLDialect interface + GetConnectStr func(dbConn *DBConnection) (string, string) + GetDDLSqlFunc func(funcName DDLSqlFuncName) (DDLSqlFunc, error) + GetDefaultTypeName func(tp DefaultDBFieldType) string + GetReplaceSql func(cli DatabaseClient, table string, rd *RowData) (string, error) + GetSortedSqlFunc func(funcName SortFuncName) (SortedSqlFunc, error) + GetTableColumns func(cli DatabaseClient, database, tableName string) ([]*DBColumn, error) + IsTableExist func(cli DatabaseClient, tableName string) (bool, error) + MakeSureDBExists func(cli DatabaseClient, dbName string) error + PreProcess func(sql string, param ...int) string + ReadSQLFile func(r io.Reader, callback FuncSQLStatementCallback, ...) error + func GetSqlDialect(dbtype string) (SQLDialect, bool) + type SQLOperationType string + const SQLOperationCount + const SQLOperationDelete + const SQLOperationInsert + const SQLOperationReplace + const SQLOperationSelect + const SQLOperationUnknown + const SQLOperationUpdate + const SQLOperationUpsert + type SQLParseError struct + ErrorType string + LineNum int + LineText string + Message string + func (e *SQLParseError) Error() string + type SQLStatement struct + Content string + EndLine int + Index int + StartLine int + Type string + type SQLType interface + AsInt func() int + IsBlock func() bool + IsNull func() bool + String func() string + type SchemaInspector interface + GetTableColumns func(ctx context.Context, database, tableName string) ([]*DBColumn, error) + GetTableNames func(ctx context.Context, database string) ([]string, error) + IsTableExist func(ctx context.Context, tableName string) (bool, error) + type SimpleExpr struct + Alias string + Field string + Schema string + Table string + Value Expression + func (se *SimpleExpr) GetFields() []string + func (se *SimpleExpr) SetAlias(alias string) Expression + func (se *SimpleExpr) ToSQL(dt DatabaseTransformer) (string, error) + type SortFuncName string + const FuncNameSortFunctions + const FuncNameSortProcedures + const FuncNameSortTables + type SortedSqlFunc func(cli DatabaseClient, names []string) ([]*SqlContent, error) + type SqlContent struct + Content string + Name string + type SubQuery struct + Alias string + Builder SQLBuilder + func (s *SubQuery) GetAlias() string + func (s *SubQuery) GetFields() []string + func (s *SubQuery) SetAlias(alias string) Expression + func (s *SubQuery) ToCondition(dt DatabaseTransformer) (*Condition, error) + func (s *SubQuery) ToSQL(dt DatabaseTransformer) (string, error) + type Table struct + Alias string + Name string + Schema string + func (t *Table) GetAlias() string + func (t *Table) ToSQL(dt DatabaseTransformer) (string, error) + type TableSource interface + GetAlias func() string + ToSQL func(dt DatabaseTransformer) (string, error) + func ALIAS(table string, alias string) TableSource + func SUBQUERY(builder SQLBuilder, alias ...string) TableSource + func TABLE(param ...string) TableSource + type TraceWord struct + Key string + NextKeys map[string]SQLType + Skip int + type Transaction interface + Commit func() error + Rollback func() error + type TransactionManager interface + Begin func(ctx context.Context) (Transaction, error) + BeginTx func(ctx context.Context, opts *sql.TxOptions) (Transaction, error) + type TypedQueryExecutor interface + Get func(ctx context.Context, dest any, query string, args ...any) error + Select func(ctx context.Context, dest any, query string, args ...any) error + type Value interface + GetValue func() (string, error) + type WhenThenClause struct + Then Expression + When Expression + type Where interface + ToCondition func(dt DatabaseTransformer) (*Condition, error) + func AND(conditions ...Where) Where + func BETWEEN(field string, start, end any, f ...WhereOptionFunc) Where + func COMBINE(andConditions []Where, orConditions []Where) Where + func EQ(field string, f ...WhereOptionFunc) Where + func EXISTS(subquery Expression, f ...WhereOptionFunc) Where + func GT(field string, f ...WhereOptionFunc) Where + func GTE(field string, f ...WhereOptionFunc) Where + func IN(field string, values []any, f ...WhereOptionFunc) Where + func IS_NOT_NULL(field string, f ...WhereOptionFunc) Where + func IS_NULL(field string, f ...WhereOptionFunc) Where + func LIKE(field string, value string, pt LikePatternType, f ...WhereOptionFunc) Where + func LIKEC(field string, value string, f ...WhereOptionFunc) Where + func LIKEL(field string, value string, f ...WhereOptionFunc) Where + func LIKER(field string, value string, f ...WhereOptionFunc) Where + func LT(field string, f ...WhereOptionFunc) Where + func LTE(field string, f ...WhereOptionFunc) Where + func MergeWhere(w1 Where, w2 Where) Where + func NEQ(field string, f ...WhereOptionFunc) Where + func NOT_EXISTS(subquery Expression, f ...WhereOptionFunc) Where + func NOT_IN(field string, values []any, f ...WhereOptionFunc) Where + func ON(leftField any, rightField any, op ...string) Where + func OR(conditions ...Where) Where + func WHERE(field string, value any, ops ...OP) Where + type WhereOP string + const WhereOPAnd + const WhereOPOr + type WhereOptionFunc func(*whereItem) *whereItem + func WithLiteral(v any) WhereOptionFunc + func WithNativeValue(v any) WhereOptionFunc + func WithParameter(name string) WhereOptionFunc