ck

package
v0.0.0-...-212a885 Latest Latest
Warning

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

Go to latest
Published: Apr 1, 2024 License: GPL-3.0 Imports: 14 Imported by: 1

Documentation

Overview

* @Date: 2022-11-30 16:05:41 * @LastEditors: fuzhuang * @LastEditTime: 2023-12-11 09:32:42 * @FilePath: \golib\ck\ck_db.go * @Description:

* @Author: Wangjun * @Date: 2021-07-12 16:25:12 * @LastEditTime: 2023-07-14 13:50:51 * @LastEditors: Wangjun * @Description:clickhouse group组 * @FilePath: \sourcedatad:\go\src\gitee.com\haodreams\golib\ck\ck_group.go * hnxr

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CKGroup

type CKGroup struct {
	// contains filtered or unexported fields
}

func NewCKGroup

func NewCKGroup(host string, datasource string, tablePrefixs ...string) (g *CKGroup)

*

  • @description: 创建一个group数组
  • @param {string} hosts
  • @param {string} dsn
  • @return {*}

func (*CKGroup) Find

func (m *CKGroup) Find(dbIdx int, dest interface{}, conds ...interface{}) (err error)

func (*CKGroup) GetDB

func (m *CKGroup) GetDB() *gorm.DB

*

  • @description: 获取数据库DB
  • @param {*}
  • @return {*}

func (*CKGroup) RawFind

func (m *CKGroup) RawFind(dbIdx int, dest interface{}, sql string, values ...interface{}) (err error)

func (*CKGroup) RawScan

func (m *CKGroup) RawScan(dbIdx int, dest interface{}, sql string, values ...interface{}) (err error)

type CKGroups

type CKGroups struct {
	Num int //group 分库数
	// contains filtered or unexported fields
}

func (*CKGroups) Exec

func (m *CKGroups) Exec(sql string) (err error)

*

  • @description: 每个主机上都执行sql命令
  • @param {string} sql
  • @return {*}

func (*CKGroups) Find

func (m *CKGroups) Find(dest interface{}, conds ...interface{}) (err error)

*

  • @description: 查找全部
  • @param {interface{}} dest 数组地址
  • @param {...interface{}} conds
  • @return {*}

func (*CKGroups) GetDB

func (m *CKGroups) GetDB() (db *gorm.DB)

func (*CKGroups) GetGroupCount

func (m *CKGroups) GetGroupCount() int

*

  • @description: 获取组数量
  • @param {*}
  • @return {*}

func (*CKGroups) Init

func (m *CKGroups) Init(conf config.Configer) (err error)

*

  • @description: host11,host12;host21,host22 ,group用分号分隔,host用逗号分隔
  • @param {config.Configer} conf
  • @return {*}

func (*CKGroups) InitArray

func (m *CKGroups) InitArray(data []string) (ck *CKGroups, err error)

*

  • @description: host11,host12;host21,host22 ,group用分号分隔,host用逗号分隔
  • @param {config.Configer} conf
  • @return {*}

func (*CKGroups) Insert

func (m *CKGroups) Insert(sql string, rows [][]interface{}) (count int, validGroup int64, err error)

*

  • @description: 并发写入clickhouse数据
  • @param {interface{}} rows 对象数组
  • @return {*}

func (*CKGroups) InsertNoEnable

func (m *CKGroups) InsertNoEnable(sql string, rows [][]interface{}) (count int, validGroup int64, err error)

*

  • @description: 并发写入clickhouse数据
  • @param {interface{}} rows 对象数组
  • 不判断enable
  • @return {*}

func (*CKGroups) InsertObjects

func (m *CKGroups) InsertObjects(rows interface{}) (count int, validGroup int64, err error)

*公用方法-写入clickhouse数据库 *param(clickhouse连接,json数组) *return(变化行数,错误信息)

func (*CKGroups) InsertObjectsNoEnable

func (m *CKGroups) InsertObjectsNoEnable(rows interface{}) (count int, validGroup int64, err error)

*公用方法-写入clickhouse数据库 *不判断enable *param(clickhouse连接,json数组) *return(变化行数,错误信息)

func (*CKGroups) RawFind

func (m *CKGroups) RawFind(dest interface{}, sql string, values ...interface{}) (err error)

*

  • @description: 使用原生sql 查找全部
  • @param {interface{}} dest
  • @param {string} sql
  • @param {...interface{}} values
  • @return {*}

func (*CKGroups) RawScan

func (m *CKGroups) RawScan(dest interface{}, sql string, values ...interface{}) (err error)

*

  • @description: 使用原生sql 查找一行
  • @param {interface{}} dest
  • @param {string} sql
  • @param {...interface{}} values
  • @return {*}

func (*CKGroups) Setup

func (m *CKGroups) Setup(conf config.Configer) (err error)

Setup 初始化配置

type DB

type DB struct {
	*gorm.DB
	// contains filtered or unexported fields
}

func (*DB) Enabled

func (m *DB) Enabled() bool

*

  • @description:是否启用
  • @return {*}

func (*DB) Exec

func (m *DB) Exec(sql string, values ...interface{}) (tx *DB)

func (*DB) Insert

func (m *DB) Insert(sql string, rows [][]interface{}) (count int, err error)

*

  • @description: 写入数据到clickhouse
  • @param {int} dbIdx 使用第几个DB
  • @param {interface{}} rows
  • @return {*}

func (*DB) InsertObjects

func (m *DB) InsertObjects(rows interface{}) (count int, err error)

*公用方法-写入clickhouse数据库 *param(clickhouse连接,json数组) *return(变化行数,错误信息)

func (*DB) Setup

func (m *DB) Setup(dsn string, enable bool) (err error)

Jump to

Keyboard shortcuts

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