Documentation ¶
Index ¶
- Variables
- func ConnectDB() error
- func DBPing() error
- type DBOperation
- func (db *DBOperation) Conto_Json(rows *sql.Rows) ([]map[string]interface{}, error)
- func (db *DBOperation) Conto_JsonbyList(rows *sql.Rows) (map[string][]interface{}, int, int, error)
- func (db *DBOperation) ExeSPwithRow(procedureName string, args ...interface{}) (*sql.Rows, error)
- func (db *DBOperation) ExecSP(procedureName string, args ...interface{}) error
- func (db *DBOperation) ExecSP_Json(procedureName string, args ...interface{}) ([]map[string]interface{}, error)
- func (db *DBOperation) Query(querystr string, args ...interface{}) (*sql.Rows, error)
- func (db *DBOperation) Query_Json(querystr string, args ...interface{}) ([]map[string]interface{}, error)
- func (db *DBOperation) QuerybyList(querystr string, namelist []string, inputs map[string]interface{}, ...) (map[string][]interface{}, int, int, error)
- func (db *DBOperation) TableDelete(TableName string, Where string) (int64, error)
- func (db *DBOperation) TableInsert(TableName string, Columns []string, Values []string) (int64, error)
- func (db *DBOperation) TableUpdate(TableName string, Columns []string, Values []string, datatypes []int, ...) (int64, error)
Constants ¶
This section is empty.
Variables ¶
var ( /* mysql,sqlserver, goracle */ DatabaseType = "mysql" /* user:password@tcp(localhost:3306)/mydb server=%s;port=%d;user id=%s;password=%s;database=%s */ //DatabaseConnection = "server=xxx;user id=xx;password=xxx;database=xxx" //sqlserver DatabaseConnection = "user:iacf12345678@tcp(localhost:3306)/iac" MaxIdleConns = 5 MaxOpenConns = 10 )
var DB *sql.DB
DB is the interface for database connection
Functions ¶
Types ¶
type DBOperation ¶
type DBOperation struct { DBTx *sql.Tx ModuleName string User string // contains filtered or unexported fields }
func NewDBOperation ¶
func NewDBOperation(User string, DBTx *sql.Tx, moduleName string) *DBOperation
func (*DBOperation) Conto_Json ¶
func (db *DBOperation) Conto_Json(rows *sql.Rows) ([]map[string]interface{}, error)
func (*DBOperation) Conto_JsonbyList ¶
func (*DBOperation) ExeSPwithRow ¶
func (db *DBOperation) ExeSPwithRow(procedureName string, args ...interface{}) (*sql.Rows, error)
func (*DBOperation) ExecSP ¶
func (db *DBOperation) ExecSP(procedureName string, args ...interface{}) error
func (*DBOperation) ExecSP_Json ¶
func (db *DBOperation) ExecSP_Json(procedureName string, args ...interface{}) ([]map[string]interface{}, error)
func (*DBOperation) Query ¶
func (db *DBOperation) Query(querystr string, args ...interface{}) (*sql.Rows, error)
func (*DBOperation) Query_Json ¶
func (db *DBOperation) Query_Json(querystr string, args ...interface{}) ([]map[string]interface{}, error)
func (*DBOperation) QuerybyList ¶
func (*DBOperation) TableDelete ¶
func (db *DBOperation) TableDelete(TableName string, Where string) (int64, error)
TableDelete deletes records from a table based on the provided WHERE clause. It returns the number of affected rows and an error, if any. The function measures the performance duration of the operation using the PerformanceWithDuration method of the db.iLog object.
func (*DBOperation) TableInsert ¶
func (db *DBOperation) TableInsert(TableName string, Columns []string, Values []string) (int64, error)
TableInsert inserts data into a specified table in the database. It takes the table name, column names, and corresponding values as input. It returns the last insert ID and any error encountered during the operation. The function measures the performance duration of the operation using the PerformanceWithDuration method of the db.iLog object.
func (*DBOperation) TableUpdate ¶
func (db *DBOperation) TableUpdate(TableName string, Columns []string, Values []string, datatypes []int, Where string) (int64, error)
TableUpdate updates the specified table with the given columns, values, data types, and WHERE clause. It returns the number of rows affected and any error encountered during the update operation. The function measures the performance duration of the operation using the PerformanceWithDuration method of the db.iLog object. If there is a panic during the execution, it logs an error message with the error details.