Versions in this module Expand all Collapse all v1 v1.2.25 Jul 20, 2023 Changes in this version + const DELETE + const DriverMssql + const DriverMysql + const DriverOceanBase + const DriverPostgresql + const DriverSqlite + const INSERT + const QUERY + const UPDATE + var BoolTypeList = []DatabaseType + var FloatTypeList = []DatabaseType + var IntTypeList = []DatabaseType + var SQLPool = sync.Pool + var StringTypeList = []DatabaseType + var UintTypeList = []DatabaseType + func CheckError(err error, t int) bool + func CommonBeginTxWithLevel(db *sql.DB, level sql.IsolationLevel) *sql.Tx + func CommonExec(db *sql.DB, query string, args ...interface{}) (sql.Result, error) + func CommonExecWithTx(tx *sql.Tx, query string, args ...interface{}) (sql.Result, error) + func CommonQuery(db *sql.DB, query string, args ...interface{}) ([]map[string]interface{}, error) + func CommonQueryWithTx(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error) + func Contains(v DatabaseType, a []DatabaseType) bool + func GetAggregationExpression(driver, field, headField, delimiter string) string + func RecycleSQL(sql *SQL) + func SetColVarType(colVar *[]interface{}, i int, typeName string) + func SetResultValue(result *map[string]interface{}, index string, colVar interface{}, ...) + type Base struct + Configs config.DatabaseList + DbList map[string]*sql.DB + Once sync.Once + func (db *Base) Close() []error + func (db *Base) CreateDB(name string, beans ...interface{}) error + func (db *Base) GetConfig(name string) config.Database + func (db *Base) GetDB(key string) *sql.DB + type Connection interface + BeginTx func() *sql.Tx + BeginTxAndConnection func(conn string) *sql.Tx + BeginTxWithLevel func(level sql.IsolationLevel) *sql.Tx + BeginTxWithLevelAndConnection func(conn string, level sql.IsolationLevel) *sql.Tx + BeginTxWithReadCommitted func() *sql.Tx + BeginTxWithReadCommittedAndConnection func(conn string) *sql.Tx + BeginTxWithReadUncommitted func() *sql.Tx + BeginTxWithReadUncommittedAndConnection func(conn string) *sql.Tx + BeginTxWithRepeatableRead func() *sql.Tx + BeginTxWithRepeatableReadAndConnection func(conn string) *sql.Tx + Close func() []error + CreateDB func(name string, beans ...interface{}) error + Exec func(query string, args ...interface{}) (sql.Result, error) + ExecWith func(tx *sql.Tx, conn, query string, args ...interface{}) (sql.Result, error) + ExecWithConnection func(conn, query string, args ...interface{}) (sql.Result, error) + ExecWithTx func(tx *sql.Tx, query string, args ...interface{}) (sql.Result, error) + GetConfig func(name string) config.Database + GetDB func(key string) *sql.DB + GetDelimiter func() string + GetDelimiter2 func() string + GetDelimiters func() []string + InitDB func(cfg map[string]config.Database) Connection + Name func() string + Query func(query string, args ...interface{}) ([]map[string]interface{}, error) + QueryWith func(tx *sql.Tx, conn, query string, args ...interface{}) ([]map[string]interface{}, error) + QueryWithConnection func(conn, query string, args ...interface{}) ([]map[string]interface{}, error) + QueryWithTx func(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error) + func GetConnection(srvs service.List) Connection + func GetConnectionByDriver(driver string) Connection + func GetConnectionFromService(srv interface{}) Connection + type DatabaseType string + const Bigint + const Bigserial + const Binary + const Bit + const Blob + const Bool + const Boolean + const Box + const Bpchar + const Char + const Character + const Cidr + const Circle + const Clob + const Date + const Datetime + const Decimal + const Double + const Doubleprecision + const Enum + const Float + const Float4 + const Float8 + const Geometry + const Geometrycollection + const Inet + const Int + const Int2 + const Int4 + const Int8 + const Integer + const Interval + const JSON + const Line + const Linestring + const Longblob + const Longtext + const Lseg + const Macaddr + const Mediumblob + const Mediumint + const Mediumtext + const Money + const Multilinestring + const Multipoint + const Multipolygon + const Name + const Nativecharacter + const Nchar + const Numeric + const Nvarchar + const Path + const Point + const Polygon + const Real + const Serial + const Set + const Smallint + const Smallserial + const Text + const Time + const Timestamp + const Timestamptz + const Timetz + const Tinyblob + const Tinyint + const Tinytext + const UUID + const Varbinary + const Varchar + const Varyingcharacter + const Year + func DT(s string) DatabaseType + func GetDTAndCheck(s string) DatabaseType + type H map[string]interface + type Mssql struct + func GetMssqlDB() *Mssql + func (db *Mssql) BeginTx() *sql.Tx + func (db *Mssql) BeginTxAndConnection(conn string) *sql.Tx + func (db *Mssql) BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx + func (db *Mssql) BeginTxWithLevelAndConnection(conn string, level sql.IsolationLevel) *sql.Tx + func (db *Mssql) BeginTxWithReadCommitted() *sql.Tx + func (db *Mssql) BeginTxWithReadCommittedAndConnection(conn string) *sql.Tx + func (db *Mssql) BeginTxWithReadUncommitted() *sql.Tx + func (db *Mssql) BeginTxWithReadUncommittedAndConnection(conn string) *sql.Tx + func (db *Mssql) BeginTxWithRepeatableRead() *sql.Tx + func (db *Mssql) BeginTxWithRepeatableReadAndConnection(conn string) *sql.Tx + func (db *Mssql) Exec(query string, args ...interface{}) (sql.Result, error) + func (db *Mssql) ExecWith(tx *sql.Tx, conn, query string, args ...interface{}) (sql.Result, error) + func (db *Mssql) ExecWithConnection(con string, query string, args ...interface{}) (sql.Result, error) + func (db *Mssql) ExecWithTx(tx *sql.Tx, query string, args ...interface{}) (sql.Result, error) + func (db *Mssql) GetDelimiter() string + func (db *Mssql) GetDelimiter2() string + func (db *Mssql) GetDelimiters() []string + func (db *Mssql) InitDB(cfgs map[string]config.Database) Connection + func (db *Mssql) Name() string + func (db *Mssql) Query(query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Mssql) QueryWith(tx *sql.Tx, conn, query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Mssql) QueryWithConnection(con string, query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Mssql) QueryWithTx(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error) + type Mysql struct + func GetMysqlDB() *Mysql + func (db *Mysql) BeginTx() *sql.Tx + func (db *Mysql) BeginTxAndConnection(conn string) *sql.Tx + func (db *Mysql) BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx + func (db *Mysql) BeginTxWithLevelAndConnection(conn string, level sql.IsolationLevel) *sql.Tx + func (db *Mysql) BeginTxWithReadCommitted() *sql.Tx + func (db *Mysql) BeginTxWithReadCommittedAndConnection(conn string) *sql.Tx + func (db *Mysql) BeginTxWithReadUncommitted() *sql.Tx + func (db *Mysql) BeginTxWithReadUncommittedAndConnection(conn string) *sql.Tx + func (db *Mysql) BeginTxWithRepeatableRead() *sql.Tx + func (db *Mysql) BeginTxWithRepeatableReadAndConnection(conn string) *sql.Tx + func (db *Mysql) Exec(query string, args ...interface{}) (sql.Result, error) + func (db *Mysql) ExecWith(tx *sql.Tx, conn, query string, args ...interface{}) (sql.Result, error) + func (db *Mysql) ExecWithConnection(con string, query string, args ...interface{}) (sql.Result, error) + func (db *Mysql) ExecWithTx(tx *sql.Tx, query string, args ...interface{}) (sql.Result, error) + func (db *Mysql) GetDelimiter() string + func (db *Mysql) GetDelimiter2() string + func (db *Mysql) GetDelimiters() []string + func (db *Mysql) InitDB(cfgs map[string]config.Database) Connection + func (db *Mysql) Name() string + func (db *Mysql) Query(query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Mysql) QueryWith(tx *sql.Tx, conn, query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Mysql) QueryWithConnection(con string, query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Mysql) QueryWithTx(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error) + type OceanBase struct + func GetOceanBaseDB() *OceanBase + func (db *OceanBase) BeginTx() *sql.Tx + func (db *OceanBase) BeginTxAndConnection(conn string) *sql.Tx + func (db *OceanBase) BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx + func (db *OceanBase) BeginTxWithLevelAndConnection(conn string, level sql.IsolationLevel) *sql.Tx + func (db *OceanBase) BeginTxWithReadCommitted() *sql.Tx + func (db *OceanBase) BeginTxWithReadCommittedAndConnection(conn string) *sql.Tx + func (db *OceanBase) BeginTxWithReadUncommitted() *sql.Tx + func (db *OceanBase) BeginTxWithReadUncommittedAndConnection(conn string) *sql.Tx + func (db *OceanBase) BeginTxWithRepeatableRead() *sql.Tx + func (db *OceanBase) BeginTxWithRepeatableReadAndConnection(conn string) *sql.Tx + func (db *OceanBase) Exec(query string, args ...interface{}) (sql.Result, error) + func (db *OceanBase) ExecWith(tx *sql.Tx, conn, query string, args ...interface{}) (sql.Result, error) + func (db *OceanBase) ExecWithConnection(con string, query string, args ...interface{}) (sql.Result, error) + func (db *OceanBase) ExecWithTx(tx *sql.Tx, query string, args ...interface{}) (sql.Result, error) + func (db *OceanBase) GetDelimiter() string + func (db *OceanBase) GetDelimiter2() string + func (db *OceanBase) GetDelimiters() []string + func (db *OceanBase) InitDB(cfgs map[string]config.Database) Connection + func (db *OceanBase) Name() string + func (db *OceanBase) Query(query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *OceanBase) QueryWith(tx *sql.Tx, conn, query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *OceanBase) QueryWithConnection(con string, query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *OceanBase) QueryWithTx(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error) + type Postgresql struct + func GetPostgresqlDB() *Postgresql + func (db *Postgresql) BeginTx() *sql.Tx + func (db *Postgresql) BeginTxAndConnection(conn string) *sql.Tx + func (db *Postgresql) BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx + func (db *Postgresql) BeginTxWithLevelAndConnection(conn string, level sql.IsolationLevel) *sql.Tx + func (db *Postgresql) BeginTxWithReadCommitted() *sql.Tx + func (db *Postgresql) BeginTxWithReadCommittedAndConnection(conn string) *sql.Tx + func (db *Postgresql) BeginTxWithReadUncommitted() *sql.Tx + func (db *Postgresql) BeginTxWithReadUncommittedAndConnection(conn string) *sql.Tx + func (db *Postgresql) BeginTxWithRepeatableRead() *sql.Tx + func (db *Postgresql) BeginTxWithRepeatableReadAndConnection(conn string) *sql.Tx + func (db *Postgresql) Exec(query string, args ...interface{}) (sql.Result, error) + func (db *Postgresql) ExecWith(tx *sql.Tx, conn, query string, args ...interface{}) (sql.Result, error) + func (db *Postgresql) ExecWithConnection(con string, query string, args ...interface{}) (sql.Result, error) + func (db *Postgresql) ExecWithTx(tx *sql.Tx, query string, args ...interface{}) (sql.Result, error) + func (db *Postgresql) GetDelimiter() string + func (db *Postgresql) GetDelimiter2() string + func (db *Postgresql) GetDelimiters() []string + func (db *Postgresql) InitDB(cfgList map[string]config.Database) Connection + func (db *Postgresql) Name() string + func (db *Postgresql) Query(query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Postgresql) QueryWith(tx *sql.Tx, conn, query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Postgresql) QueryWithConnection(con string, query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Postgresql) QueryWithTx(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error) + type SQL struct + func Table(table string) *SQL + func WithDriver(conn Connection) *SQL + func WithDriverAndConnection(connName string, conn Connection) *SQL + func (sql *SQL) All() ([]map[string]interface{}, error) + func (sql *SQL) Avg(field string) (interface{}, error) + func (sql *SQL) Count() (int64, error) + func (sql *SQL) Delete() error + func (sql *SQL) Exec() (int64, error) + func (sql *SQL) Find(arg interface{}) (map[string]interface{}, error) + func (sql *SQL) First() (map[string]interface{}, error) + func (sql *SQL) GroupBy(fields ...string) *SQL + func (sql *SQL) GroupByRaw(group string) *SQL + func (sql *SQL) Insert(values dialect.H) (int64, error) + func (sql *SQL) LeftJoin(table string, fieldA string, operation string, fieldB string) *SQL + func (sql *SQL) Max(field string) (interface{}, error) + func (sql *SQL) Min(field string) (interface{}, error) + func (sql *SQL) OrderBy(fields ...string) *SQL + func (sql *SQL) OrderByRaw(order string) *SQL + func (sql *SQL) Select(fields ...string) *SQL + func (sql *SQL) ShowColumns() ([]map[string]interface{}, error) + func (sql *SQL) ShowTables() ([]string, error) + func (sql *SQL) Skip(offset int) *SQL + func (sql *SQL) Sum(field string) (float64, error) + func (sql *SQL) Table(table string) *SQL + func (sql *SQL) Take(take int) *SQL + func (sql *SQL) Update(values dialect.H) (int64, error) + func (sql *SQL) UpdateRaw(raw string, args ...interface{}) *SQL + func (sql *SQL) Where(field string, operation string, arg interface{}) *SQL + func (sql *SQL) WhereIn(field string, arg []interface{}) *SQL + func (sql *SQL) WhereNotIn(field string, arg []interface{}) *SQL + func (sql *SQL) WhereRaw(raw string, args ...interface{}) *SQL + func (sql *SQL) WithConnection(conn string) *SQL + func (sql *SQL) WithDriver(conn Connection) *SQL + func (sql *SQL) WithTransaction(fn TxFn) (res map[string]interface{}, err error) + func (sql *SQL) WithTransactionByLevel(level dbsql.IsolationLevel, fn TxFn) (res map[string]interface{}, err error) + func (sql *SQL) WithTx(tx *dbsql.Tx) *SQL + type SQLTx struct + Tx *sql.Tx + type Sqlite struct + func GetSqliteDB() *Sqlite + func (db *Sqlite) BeginTx() *sql.Tx + func (db *Sqlite) BeginTxAndConnection(conn string) *sql.Tx + func (db *Sqlite) BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx + func (db *Sqlite) BeginTxWithLevelAndConnection(conn string, level sql.IsolationLevel) *sql.Tx + func (db *Sqlite) BeginTxWithReadCommitted() *sql.Tx + func (db *Sqlite) BeginTxWithReadCommittedAndConnection(conn string) *sql.Tx + func (db *Sqlite) BeginTxWithReadUncommitted() *sql.Tx + func (db *Sqlite) BeginTxWithReadUncommittedAndConnection(conn string) *sql.Tx + func (db *Sqlite) BeginTxWithRepeatableRead() *sql.Tx + func (db *Sqlite) BeginTxWithRepeatableReadAndConnection(conn string) *sql.Tx + func (db *Sqlite) Exec(query string, args ...interface{}) (sql.Result, error) + func (db *Sqlite) ExecWith(tx *sql.Tx, conn, query string, args ...interface{}) (sql.Result, error) + func (db *Sqlite) ExecWithConnection(con string, query string, args ...interface{}) (sql.Result, error) + func (db *Sqlite) ExecWithTx(tx *sql.Tx, query string, args ...interface{}) (sql.Result, error) + func (db *Sqlite) GetDelimiter() string + func (db *Sqlite) GetDelimiter2() string + func (db *Sqlite) GetDelimiters() []string + func (db *Sqlite) InitDB(cfgList map[string]config.Database) Connection + func (db *Sqlite) Name() string + func (db *Sqlite) Query(query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Sqlite) QueryWith(tx *sql.Tx, conn, query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Sqlite) QueryWithConnection(con string, query string, args ...interface{}) ([]map[string]interface{}, error) + func (db *Sqlite) QueryWithTx(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error) + type TxFn func(tx *dbsql.Tx) (error, map[string]interface{}) + type Value string + func GetValueFromDatabaseType(typ DatabaseType, value interface{}, json bool) Value + func GetValueFromJSONOfDatabaseType(typ DatabaseType, value interface{}) Value + func GetValueFromSQLOfDatabaseType(typ DatabaseType, value interface{}) Value + func (v Value) HTML() template.HTML + func (v Value) String() string + func (v Value) ToInt64() int64