dbconn

package
v0.0.0-...-df163ab Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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
)
View Source
var DB *sql.DB

DB is the interface for database connection

Functions

func ConnectDB

func ConnectDB() error

func DBPing

func DBPing() error

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 (db *DBOperation) Conto_JsonbyList(rows *sql.Rows) (map[string][]interface{}, int, int, error)

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 (db *DBOperation) QuerybyList(querystr string, namelist []string, inputs map[string]interface{}, finputs []types.Input) (map[string][]interface{}, int, int, error)

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.

Directories

Path Synopsis
orm
The original package is migrated from beego and modified, you can find orignal from following link:
The original package is migrated from beego and modified, you can find orignal from following link:

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL