Documentation ¶
Index ¶
- Constants
- Variables
- 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 FieldType, a []FieldType) 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
- type Connection
- type FieldType
- type H
- type 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(conn 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(conn 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
- 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(conn 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(conn 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 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(conn 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(conn 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
- 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
- type 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(conn 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(conn 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
- type Value
Constants ¶
const ( // DriverMysql is a const value of mysql driver. DriverMysql = "mysql" // DriverSqlite is a const value of sqlite driver. DriverSqlite = "sqlite" // DriverPostgresql is a const value of postgresql driver. DriverPostgresql = "postgresql" // DriverMssql is a const value of mssql driver. DriverMssql = "mssql" )
const ( INSERT = 0 DELETE = 1 UPDATE = 2 QUERY = 3 )
Variables ¶
var ( // StringTypeList is a FieldType list of string. StringTypeList = []FieldType{Date, Time, Year, Datetime, Timestamptz, Timestamp, Timetz, Varchar, Char, Mediumtext, Longtext, Tinytext, Text, JSON, Blob, Tinyblob, Mediumblob, Longblob, Interval, Point, Bpchar, Line, Lseg, Box, Path, Polygon, Circle, Cidr, Inet, Macaddr, Character, Varyingcharacter, Nchar, Nativecharacter, Nvarchar, Clob, Binary, Varbinary, Enum, Set, Geometry, Multilinestring, Multipolygon, Linestring, Multipoint, Geometrycollection, Name, UUID, Timestamptz, Name, UUID, Inet} // BoolTypeList is a FieldType list of bool. BoolTypeList = []FieldType{Bool, Boolean} // IntTypeList is a FieldType list of integer. IntTypeList = []FieldType{Int4, Int2, Int8, Int, Tinyint, Mediumint, Smallint, Smallserial, Serial, Bigserial, Integer, Bigint} // FloatTypeList is a FieldType list of float. FloatTypeList = []FieldType{Float, Float4, Float8, Double, Real, Doubleprecision} // UintTypeList is a FieldType list of uint. UintTypeList = []FieldType{Decimal, Bit, Money, Numeric} )
var SQLPool = sync.Pool{ New: func() interface{} { return &SQL{ SQLComponent: dialect.SQLComponent{ Fields: make([]string, 0), TableName: "", Args: make([]interface{}, 0), Wheres: make([]dialect.Where, 0), Leftjoins: make([]dialect.Join, 0), UpdateRaws: make([]dialect.RawUpdate, 0), WhereRaws: "", Order: "", Group: "", Limit: "", }, diver: nil, dialect: nil, } }, }
SQLPool is a object pool of SQL.
Functions ¶
func CheckError ¶
func CommonBeginTxWithLevel ¶
CommonBeginTxWithLevel starts a transaction with given transaction isolation level and db connection.
func CommonExec ¶
CommonExec is a common method of exec.
func CommonExecWithTx ¶
CommonExecWithTx is a common method of exec.
func CommonQuery ¶
CommonQuery is a common method of query.
func CommonQueryWithTx ¶
func CommonQueryWithTx(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error)
CommonQueryWithTx is a common method of query.
func SetColVarType ¶
SetColVarType set the column type.
func SetResultValue ¶
func SetResultValue(result *map[string]interface{}, index string, colVar interface{}, typeName string)
SetResultValue set the result value.
Types ¶
type Connection ¶
type Connection interface { // Query is the query method of sql. Query(query string, args ...interface{}) ([]map[string]interface{}, error) // Exec is the exec method of sql. Exec(query string, args ...interface{}) (sql.Result, error) // QueryWithConnection is the query method with given connection of sql. QueryWithConnection(conn, query string, args ...interface{}) ([]map[string]interface{}, error) QueryWithTx(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error) QueryWith(tx *sql.Tx, conn, query string, args ...interface{}) ([]map[string]interface{}, error) // ExecWithConnection is the exec method with given connection of sql. ExecWithConnection(conn, query string, args ...interface{}) (sql.Result, error) ExecWithTx(tx *sql.Tx, query string, args ...interface{}) (sql.Result, error) ExecWith(tx *sql.Tx, conn, query string, args ...interface{}) (sql.Result, error) BeginTxWithReadUncommitted() *sql.Tx BeginTxWithReadCommitted() *sql.Tx BeginTxWithRepeatableRead() *sql.Tx BeginTx() *sql.Tx BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx BeginTxWithReadUncommittedAndConnection(conn string) *sql.Tx BeginTxWithReadCommittedAndConnection(conn string) *sql.Tx BeginTxWithRepeatableReadAndConnection(conn string) *sql.Tx BeginTxAndConnection(conn string) *sql.Tx BeginTxWithLevelAndConnection(conn string, level sql.IsolationLevel) *sql.Tx // InitDB initialize the database connections. InitDB(cfg map[string]config.Database) Connection // GetName get the connection name. Name() string Close() []error GetDelimiter() string GetDelimiter2() string GetDelimiters() []string GetDB(key string) *sql.DB GetConfig(name string) config.Database CreateDB(name string, beans ...interface{}) error }
Connection is a connection handler of database.
func GetConnection ¶
func GetConnection(srvList service.List) Connection
func GetConnectionByDriver ¶
func GetConnectionByDriver(driver string) Connection
GetConnectionByDriver return the Connection by given driver name.
func GetConnectionFromService ¶
func GetConnectionFromService(srv interface{}) Connection
type FieldType ¶
type FieldType string
FieldType is the database field type.
const ( Int FieldType = "INT" Tinyint FieldType = "TINYINT" Mediumint FieldType = "MEDIUMINT" Smallint FieldType = "SMALLINT" Bigint FieldType = "BIGINT" Bit FieldType = "BIT" Int8 FieldType = "INT8" Int4 FieldType = "INT4" Int2 FieldType = "INT2" Integer FieldType = "INTEGER" Numeric FieldType = "NUMERIC" Smallserial FieldType = "SMALLSERIAL" Serial FieldType = "SERIAL" Bigserial FieldType = "BIGSERIAL" Money FieldType = "MONEY" Real FieldType = "REAL" Float FieldType = "FLOAT" Float4 FieldType = "FLOAT4" Float8 FieldType = "FLOAT8" Double FieldType = "DOUBLE" Decimal FieldType = "DECIMAL" Doubleprecision FieldType = "DOUBLEPRECISION" Date FieldType = "DATE" Time FieldType = "TIME" Year FieldType = "YEAR" Datetime FieldType = "DATETIME" Timestamp FieldType = "TIMESTAMP" Text FieldType = "TEXT" Longtext FieldType = "LONGTEXT" Mediumtext FieldType = "MEDIUMTEXT" Tinytext FieldType = "TINYTEXT" Varchar FieldType = "VARCHAR" Char FieldType = "CHAR" Bpchar FieldType = "BPCHAR" JSON FieldType = "JSON" Blob FieldType = "BLOB" Tinyblob FieldType = "TINYBLOB" Mediumblob FieldType = "MEDIUMBLOB" Longblob FieldType = "LONGBLOB" Interval FieldType = "INTERVAL" Boolean FieldType = "BOOLEAN" Bool FieldType = "BOOL" Point FieldType = "POINT" Line FieldType = "LINE" Lseg FieldType = "LSEG" Box FieldType = "BOX" Path FieldType = "PATH" Polygon FieldType = "POLYGON" Circle FieldType = "CIRCLE" Cidr FieldType = "CIDR" Inet FieldType = "INET" Macaddr FieldType = "MACADDR" Character FieldType = "CHARACTER" Varyingcharacter FieldType = "VARYINGCHARACTER" Nchar FieldType = "NCHAR" Nativecharacter FieldType = "NATIVECHARACTER" Nvarchar FieldType = "NVARCHAR" Clob FieldType = "CLOB" Binary FieldType = "BINARY" Varbinary FieldType = "VARBINARY" Enum FieldType = "ENUM" Set FieldType = "SET" Geometry FieldType = "GEOMETRY" Multilinestring FieldType = "MULTILINESTRING" Multipolygon FieldType = "MULTIPOLYGON" Linestring FieldType = "LINESTRING" Multipoint FieldType = "MULTIPOINT" Geometrycollection FieldType = "GEOMETRYCOLLECTION" Name FieldType = "NAME" UUID FieldType = "UUID" Timestamptz FieldType = "TIMESTAMPTZ" Timetz FieldType = "TIMETZ" )
func GetFieldType ¶
GetFieldType turn the string value into FieldType.
func GetFieldTypeAndCheck ¶
GetFieldTypeAndCheck check the FieldType.
type Mssql ¶
type Mssql struct {
Base
}
Mssql is a Connection of mssql.
func (*Mssql) BeginTxAndConnection ¶
BeginTxAndConnection starts a transaction with level LevelDefault and connection.
func (*Mssql) BeginTxWithLevel ¶
func (db *Mssql) BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx
BeginTxWithLevel starts a transaction with given transaction isolation level.
func (*Mssql) BeginTxWithLevelAndConnection ¶
BeginTxWithLevelAndConnection starts a transaction with given transaction isolation level and connection.
func (*Mssql) BeginTxWithReadCommitted ¶
BeginTxWithReadCommitted starts a transaction with level LevelReadCommitted.
func (*Mssql) BeginTxWithReadCommittedAndConnection ¶
BeginTxWithReadCommittedAndConnection starts a transaction with level LevelReadCommitted and connection.
func (*Mssql) BeginTxWithReadUncommitted ¶
BeginTxWithReadUncommitted starts a transaction with level LevelReadUncommitted.
func (*Mssql) BeginTxWithReadUncommittedAndConnection ¶
BeginTxWithReadUncommittedAndConnection starts a transaction with level LevelReadUncommitted and connection.
func (*Mssql) BeginTxWithRepeatableRead ¶
BeginTxWithRepeatableRead starts a transaction with level LevelRepeatableRead.
func (*Mssql) BeginTxWithRepeatableReadAndConnection ¶
BeginTxWithRepeatableReadAndConnection starts a transaction with level LevelRepeatableRead and connection.
func (*Mssql) ExecWithConnection ¶
func (db *Mssql) ExecWithConnection(conn string, query string, args ...interface{}) (sql.Result, error)
ExecWithConnection implements the method Connection.ExecWithConnection.
func (*Mssql) ExecWithTx ¶
ExecWithTx is exec method within the transaction.
func (*Mssql) GetDelimiter ¶
GetDelimiter implements the method Connection.GetDelimiter.
func (*Mssql) GetDelimiter2 ¶
GetDelimiter2 implements the method Connection.GetDelimiter2.
func (*Mssql) GetDelimiters ¶
GetDelimiters implements the method Connection.GetDelimiters.
func (*Mssql) InitDB ¶
func (db *Mssql) InitDB(cfgs map[string]config.Database) Connection
InitDB implements the method Connection.InitDB.
type Mysql ¶
type Mysql struct {
Base
}
Mysql is a Connection of mysql.
func (*Mysql) BeginTxAndConnection ¶
BeginTxAndConnection starts a transaction with level LevelDefault and connection.
func (*Mysql) BeginTxWithLevel ¶
func (db *Mysql) BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx
BeginTxWithLevel starts a transaction with given transaction isolation level.
func (*Mysql) BeginTxWithLevelAndConnection ¶
BeginTxWithLevelAndConnection starts a transaction with given transaction isolation level and connection.
func (*Mysql) BeginTxWithReadCommitted ¶
BeginTxWithReadCommitted starts a transaction with level LevelReadCommitted.
func (*Mysql) BeginTxWithReadCommittedAndConnection ¶
BeginTxWithReadCommittedAndConnection starts a transaction with level LevelReadCommitted and connection.
func (*Mysql) BeginTxWithReadUncommitted ¶
BeginTxWithReadUncommitted starts a transaction with level LevelReadUncommitted.
func (*Mysql) BeginTxWithReadUncommittedAndConnection ¶
BeginTxWithReadUncommittedAndConnection starts a transaction with level LevelReadUncommitted and connection.
func (*Mysql) BeginTxWithRepeatableRead ¶
BeginTxWithRepeatableRead starts a transaction with level LevelRepeatableRead.
func (*Mysql) BeginTxWithRepeatableReadAndConnection ¶
BeginTxWithRepeatableReadAndConnection starts a transaction with level LevelRepeatableRead and connection.
func (*Mysql) ExecWithConnection ¶
func (db *Mysql) ExecWithConnection(conn string, query string, args ...interface{}) (sql.Result, error)
ExecWithConnection implements the method Connection.ExecWithConnection.
func (*Mysql) ExecWithTx ¶
ExecWithTx is exec method within the transaction.
func (*Mysql) GetDelimiter ¶
GetDelimiter implements the method Connection.GetDelimiter.
func (*Mysql) GetDelimiter2 ¶
GetDelimiter2 implements the method Connection.GetDelimiter2.
func (*Mysql) GetDelimiters ¶
GetDelimiters implements the method Connection.GetDelimiters.
func (*Mysql) InitDB ¶
func (db *Mysql) InitDB(cfgs map[string]config.Database) Connection
InitDB implements the method Connection.InitDB.
type Postgresql ¶
type Postgresql struct {
Base
}
Postgresql is a Connection of postgresql.
func GetPostgresqlDB ¶
func GetPostgresqlDB() *Postgresql
GetPostgresqlDB return the global postgresql connection.
func (*Postgresql) BeginTx ¶
func (db *Postgresql) BeginTx() *sql.Tx
BeginTx starts a transaction with level LevelDefault.
func (*Postgresql) BeginTxAndConnection ¶
func (db *Postgresql) BeginTxAndConnection(conn string) *sql.Tx
BeginTxAndConnection starts a transaction with level LevelDefault and connection.
func (*Postgresql) BeginTxWithLevel ¶
func (db *Postgresql) BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx
BeginTxWithLevel starts a transaction with given transaction isolation level.
func (*Postgresql) BeginTxWithLevelAndConnection ¶
func (db *Postgresql) BeginTxWithLevelAndConnection(conn string, level sql.IsolationLevel) *sql.Tx
BeginTxWithLevelAndConnection starts a transaction with given transaction isolation level and connection.
func (*Postgresql) BeginTxWithReadCommitted ¶
func (db *Postgresql) BeginTxWithReadCommitted() *sql.Tx
BeginTxWithReadCommitted starts a transaction with level LevelReadCommitted.
func (*Postgresql) BeginTxWithReadCommittedAndConnection ¶
func (db *Postgresql) BeginTxWithReadCommittedAndConnection(conn string) *sql.Tx
BeginTxWithReadCommittedAndConnection starts a transaction with level LevelReadCommitted and connection.
func (*Postgresql) BeginTxWithReadUncommitted ¶
func (db *Postgresql) BeginTxWithReadUncommitted() *sql.Tx
BeginTxWithReadUncommitted starts a transaction with level LevelReadUncommitted.
func (*Postgresql) BeginTxWithReadUncommittedAndConnection ¶
func (db *Postgresql) BeginTxWithReadUncommittedAndConnection(conn string) *sql.Tx
BeginTxWithReadUncommittedAndConnection starts a transaction with level LevelReadUncommitted and connection.
func (*Postgresql) BeginTxWithRepeatableRead ¶
func (db *Postgresql) BeginTxWithRepeatableRead() *sql.Tx
BeginTxWithRepeatableRead starts a transaction with level LevelRepeatableRead.
func (*Postgresql) BeginTxWithRepeatableReadAndConnection ¶
func (db *Postgresql) BeginTxWithRepeatableReadAndConnection(conn string) *sql.Tx
BeginTxWithRepeatableReadAndConnection starts a transaction with level LevelRepeatableRead and connection.
func (*Postgresql) Exec ¶
func (db *Postgresql) Exec(query string, args ...interface{}) (sql.Result, error)
Exec implements the method Connection.Exec.
func (*Postgresql) ExecWithConnection ¶
func (db *Postgresql) ExecWithConnection(conn string, query string, args ...interface{}) (sql.Result, error)
ExecWithConnection implements the method Connection.ExecWithConnection.
func (*Postgresql) ExecWithTx ¶
ExecWithTx is exec method within the transaction.
func (*Postgresql) GetDelimiter ¶
func (db *Postgresql) GetDelimiter() string
GetDelimiter implements the method Connection.GetDelimiter.
func (*Postgresql) GetDelimiter2 ¶
func (db *Postgresql) GetDelimiter2() string
GetDelimiter2 implements the method Connection.GetDelimiter2.
func (*Postgresql) GetDelimiters ¶
func (db *Postgresql) GetDelimiters() []string
GetDelimiters implements the method Connection.GetDelimiters.
func (*Postgresql) InitDB ¶
func (db *Postgresql) InitDB(cfgList map[string]config.Database) Connection
InitDB implements the method Connection.InitDB.
func (*Postgresql) Name ¶
func (db *Postgresql) Name() string
Name implements the method Connection.Name.
func (*Postgresql) Query ¶
func (db *Postgresql) Query(query string, args ...interface{}) ([]map[string]interface{}, error)
Query implements the method Connection.Query.
func (*Postgresql) QueryWithConnection ¶
func (db *Postgresql) QueryWithConnection(conn string, query string, args ...interface{}) ([]map[string]interface{}, error)
QueryWithConnection implements the method Connection.QueryWithConnection.
func (*Postgresql) QueryWithTx ¶
func (db *Postgresql) QueryWithTx(tx *sql.Tx, query string, args ...interface{}) ([]map[string]interface{}, error)
QueryWithTx is query method within the transaction.
type SQL ¶
type SQL struct { dialect.SQLComponent // contains filtered or unexported fields }
SQL wraps the Connection and driver dialect methods.
func WithDriverAndConnection ¶
func WithDriverAndConnection(connName string, conn Connection) *SQL
WithDriverAndConnection return a SQL with given driver and connection name.
func (*SQL) ShowColumns ¶
ShowColumns show columns info.
func (*SQL) WhereNotIn ¶
WhereNotIn add the where operation of "not in" and argument values.
func (*SQL) WithConnection ¶
WithConnection set the connection name of SQL.
func (*SQL) WithDriver ¶
func (sql *SQL) WithDriver(conn Connection) *SQL
WithDriver return a SQL with given driver.
func (*SQL) WithTransaction ¶
WithTransaction call the callback function within the transaction and catch the error.
func (*SQL) WithTransactionByLevel ¶
func (sql *SQL) WithTransactionByLevel(level dbsql.IsolationLevel, fn TxFn) (res map[string]interface{}, err error)
WithTransactionByLevel call the callback function within the transaction of given transaction level and catch the error.
type Sqlite ¶
type Sqlite struct {
Base
}
Sqlite is a Connection of sqlite.
func (*Sqlite) BeginTxAndConnection ¶
BeginTxAndConnection starts a transaction with level LevelDefault and connection.
func (*Sqlite) BeginTxWithLevel ¶
func (db *Sqlite) BeginTxWithLevel(level sql.IsolationLevel) *sql.Tx
BeginTxWithLevel starts a transaction with given transaction isolation level.
func (*Sqlite) BeginTxWithLevelAndConnection ¶
BeginTxWithLevelAndConnection starts a transaction with given transaction isolation level and connection.
func (*Sqlite) BeginTxWithReadCommitted ¶
BeginTxWithReadCommitted starts a transaction with level LevelReadCommitted.
func (*Sqlite) BeginTxWithReadCommittedAndConnection ¶
BeginTxWithReadCommittedAndConnection starts a transaction with level LevelReadCommitted and connection.
func (*Sqlite) BeginTxWithReadUncommitted ¶
BeginTxWithReadUncommitted starts a transaction with level LevelReadUncommitted.
func (*Sqlite) BeginTxWithReadUncommittedAndConnection ¶
BeginTxWithReadUncommittedAndConnection starts a transaction with level LevelReadUncommitted and connection.
func (*Sqlite) BeginTxWithRepeatableRead ¶
BeginTxWithRepeatableRead starts a transaction with level LevelRepeatableRead.
func (*Sqlite) BeginTxWithRepeatableReadAndConnection ¶
BeginTxWithRepeatableReadAndConnection starts a transaction with level LevelRepeatableRead and connection.
func (*Sqlite) ExecWithConnection ¶
func (db *Sqlite) ExecWithConnection(conn string, query string, args ...interface{}) (sql.Result, error)
ExecWithConnection implements the method Connection.ExecWithConnection.
func (*Sqlite) ExecWithTx ¶
ExecWithTx is exec method within the transaction.
func (*Sqlite) GetDelimiter ¶
GetDelimiter implements the method Connection.GetDelimiter.
func (*Sqlite) GetDelimiter2 ¶
GetDelimiter2 implements the method Connection.GetDelimiter2.
func (*Sqlite) GetDelimiters ¶
GetDelimiters implements the method Connection.GetDelimiters.
func (*Sqlite) InitDB ¶
func (db *Sqlite) InitDB(cfgList map[string]config.Database) Connection
InitDB implements the method Connection.InitDB.
type Value ¶
type Value string
Value is a string.
func GetValueFromFieldType ¶
GetValueFromFieldType return Value of given FieldType and interface.
func GetValueFromJSONFieldType ¶
GetValueFromJSONFieldType return Value of given FieldType and interface from JSON string value.
func GetValueFromSQLFieldType ¶
GetValueFromSQLFieldType return Value of given FieldType and interface.