Documentation ¶
Index ¶
- Constants
- func FormatInsertOrUpdate(tableName string, insert interface{}) (string, []interface{})
- func InsertArray(tableName string, columnList []string, insertDataList [][]interface{}) (string, []interface{})
- func RemoveMysqlConnectionPool(db string, host string) error
- func ReplaceConnection(db string, conn *sql.DB)
- type ConnectionPoolItem
- func (connectionItem *ConnectionPoolItem) BeginTransaction() (TransactionStruct, error)
- func (connectionItem *ConnectionPoolItem) Close() error
- func (connectionItem *ConnectionPoolItem) FetchList(ctx context.Context, query string, args ...interface{}) ([]string, error)
- func (connectionItem *ConnectionPoolItem) FetchQuery(ctx context.Context, query string, args ...interface{}) (map[string]string, error)
- func (connectionItem *ConnectionPoolItem) GetAll(ctx context.Context, query string, args ...interface{}) (map[int]map[string]string, error)
- func (connectionItem *ConnectionPoolItem) Insert(ctx context.Context, tableName string, insert map[string]interface{}, ...) (int64, error)
- func (connectionItem *ConnectionPoolItem) InsertArray(ctx context.Context, tableName string, columnList []string, ...) error
- func (connectionItem *ConnectionPoolItem) InsertOrUpdate(ctx context.Context, tableName string, insert map[string]interface{}) error
- func (connectionItem *ConnectionPoolItem) Ping() error
- func (connectionItem *ConnectionPoolItem) Query(ctx context.Context, query string, args ...interface{}) error
- func (connectionItem *ConnectionPoolItem) Update(ctx context.Context, query string, args ...interface{}) (int64, error)
- type TransactionStruct
- func (transactionItem *TransactionStruct) Commit() error
- func (transactionItem *TransactionStruct) ExecQuery(ctx context.Context, query string, args ...interface{}) error
- func (transactionItem *TransactionStruct) FetchQuery(ctx context.Context, query string, args ...interface{}) (map[string]string, error)
- func (transactionItem *TransactionStruct) GetAll(ctx context.Context, query string, args ...interface{}) (map[int]map[string]string, error)
- func (transactionItem *TransactionStruct) Insert(ctx context.Context, tableName string, insert interface{}, isIgnore bool) error
- func (transactionItem *TransactionStruct) InsertArray(ctx context.Context, tableName string, columnList []string, ...)
- func (transactionItem *TransactionStruct) InsertOrUpdate(ctx context.Context, tableName string, insert map[string]interface{}) error
- func (transactionItem *TransactionStruct) Rollback() error
- func (transactionItem *TransactionStruct) Update(ctx context.Context, query string, args ...interface{}) (int64, error)
Constants ¶
const QueryTimeout = 5 * time.Second // таймаут для запросов
Variables ¶
This section is empty.
Functions ¶
func FormatInsertOrUpdate ¶ added in v1.0.0
готовим запрос для InsertOrUpdate
func InsertArray ¶ added in v1.0.0
func InsertArray(tableName string, columnList []string, insertDataList [][]interface{}) (string, []interface{})
готовим запрос для InsertArray
func RemoveMysqlConnectionPool ¶ added in v1.0.0
RemoveMysqlConnectionPool удаляем пул соединений для базы и хоста
func ReplaceConnection ¶
ReplaceConnection обновить объект пула подключений
Types ¶
type ConnectionPoolItem ¶
ConnectionPoolItem структура объекта подключения к базе данных
func CreateMysqlConnection ¶ added in v1.0.0
func CreateMysqlConnection(ctx context.Context, db string, host string, user string, pass string, maxConnections int, isSsl bool) (*ConnectionPoolItem, error)
CreateMysqlConnection создаем mysql подключение без сохранения в мапу
func GetMysqlConnection ¶
func GetMysqlConnection(ctx context.Context, db string, host string, user string, pass string, maxConnections int, isSsl bool) (*ConnectionPoolItem, error)
GetMysqlConnection получаем хранимое mysql подключение
func (*ConnectionPoolItem) BeginTransaction ¶
func (connectionItem *ConnectionPoolItem) BeginTransaction() (TransactionStruct, error)
BeginTransaction начинаем транзакцию
func (*ConnectionPoolItem) Close ¶
func (connectionItem *ConnectionPoolItem) Close() error
Close закрываем соединение
func (*ConnectionPoolItem) FetchList ¶
func (connectionItem *ConnectionPoolItem) FetchList(ctx context.Context, query string, args ...interface{}) ([]string, error)
FetchList получаем одномерный массив из запроса
func (*ConnectionPoolItem) FetchQuery ¶
func (connectionItem *ConnectionPoolItem) FetchQuery(ctx context.Context, query string, args ...interface{}) (map[string]string, error)
FetchQuery получаем ответ после запроса
func (*ConnectionPoolItem) GetAll ¶
func (connectionItem *ConnectionPoolItem) GetAll(ctx context.Context, query string, args ...interface{}) (map[int]map[string]string, error)
GetAll получаем массив из запроса
func (*ConnectionPoolItem) Insert ¶
func (connectionItem *ConnectionPoolItem) Insert(ctx context.Context, tableName string, insert map[string]interface{}, isIgnore bool) (int64, error)
Insert осуществляем запрос вставки
func (*ConnectionPoolItem) InsertArray ¶
func (connectionItem *ConnectionPoolItem) InsertArray(ctx context.Context, tableName string, columnList []string, insertDataList [][]interface{}) error
InsertArray функция для вставки массива записей в базу
func (*ConnectionPoolItem) InsertOrUpdate ¶
func (connectionItem *ConnectionPoolItem) InsertOrUpdate(ctx context.Context, tableName string, insert map[string]interface{}) error
InsertOrUpdate осуществляем запрос insert or update
func (*ConnectionPoolItem) Ping ¶
func (connectionItem *ConnectionPoolItem) Ping() error
Ping функция для пинга соединения
type TransactionStruct ¶
type TransactionStruct struct {
// contains filtered or unexported fields
}
TransactionStruct структура транзакции
func (*TransactionStruct) Commit ¶
func (transactionItem *TransactionStruct) Commit() error
Commit подтверждаем транзакцию
func (*TransactionStruct) ExecQuery ¶
func (transactionItem *TransactionStruct) ExecQuery(ctx context.Context, query string, args ...interface{}) error
ExecQuery осуществляем запрос
func (*TransactionStruct) FetchQuery ¶
func (transactionItem *TransactionStruct) FetchQuery(ctx context.Context, query string, args ...interface{}) (map[string]string, error)
FetchQuery получаем ответ после запроса
func (*TransactionStruct) GetAll ¶
func (transactionItem *TransactionStruct) GetAll(ctx context.Context, query string, args ...interface{}) (map[int]map[string]string, error)
GetAll получаем массив
func (*TransactionStruct) Insert ¶ added in v1.0.1
func (transactionItem *TransactionStruct) Insert(ctx context.Context, tableName string, insert interface{}, isIgnore bool) error
Insert осуществляем запрос insert
func (*TransactionStruct) InsertArray ¶
func (transactionItem *TransactionStruct) InsertArray(ctx context.Context, tableName string, columnList []string, insertDataList [][]interface{}, isIgnore bool)
InsertArray функция для вставки массива записей в базу
func (*TransactionStruct) InsertOrUpdate ¶
func (transactionItem *TransactionStruct) InsertOrUpdate(ctx context.Context, tableName string, insert map[string]interface{}) error
InsertOrUpdate осуществляем запрос insert or update
func (*TransactionStruct) Rollback ¶
func (transactionItem *TransactionStruct) Rollback() error
Rollback откатываем транзакцию