eDB

package module
v0.0.0-...-60d5aaf Latest Latest
Warning

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

Go to latest
Published: Sep 22, 2022 License: Apache-2.0 Imports: 9 Imported by: 0

README

eDB

基本介绍
  • 源于阿里adb客户端的实现逻辑,自行封装的批处理工具。
  • 批处理写库的go客户端,目的是为了实现数据库写操作的批量化,结构化,提高效率,规范统一代码结构.
使用方法
go get -u github.com/et-zone/eDB

说明
  • 目前不支持并发批处理,并发批处理本身存在安全隐患,可能会导致复写,或者写冲突问题。
  • 针对批处理业务不走并发更安全
  • 后期如有更好的方案会更新项目
数据表配置json文件(必须配置)
{
    "tbname1":["field1","field2","field3"],
    "tbname":[]
    
}
example
package main

import (
	"github.com/et-zone/eDB"
)

func main() {
	cfg := &eDB.EConfig{
		UserName:  "root",
		PassWord:  "mysql",
		Addr:      "127.0.0.1",
		Port:      3306,
		DB:        "test",
		TableFile: "./tbinfo.json",
	}
	row := eDB.NewRow()
	row.SetColumn(0, 0)
	row.SetColumn(1, nil)
	row.SetColumn(2, "e空间")
	// fmt.Println(row.String())

	client := eDB.InitClient(cfg)
	client.AddRow("sk", row)
	// fmt.Println(client.GettableNanme("aaa"))
	// client.FlushTx("sk")
	client.FlushAll()
}

Documentation

Index

Constants

View Source
const (
	TABLE_FIELDS = "TABLEFIELDS"
)

Variables

This section is empty.

Functions

func NewRow

func NewRow() *row

Types

type Client

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

func InitClient

func InitClient(config *EConfig) *Client

func (*Client) AddRow

func (cli *Client) AddRow(tableName string, row *row)

func (*Client) FlushAll

func (cli *Client) FlushAll() (err error)

flush DB All table

func (*Client) FlushTx

func (cli *Client) FlushTx(tableName ...string) (err error)

事务插入,必须制定哪些数据表,默认不执行插入

func (*Client) GetTableNames

func (cli *Client) GetTableNames() []string

func (*Client) SetTable

func (cli *Client) SetTable(tableName string, fields []string) error

func (*Client) String

func (cli *Client) String() string

type EConfig

type EConfig struct {
	UserName  string `json:"userName"`
	PassWord  string `json:"passWord"`
	Addr      string `json:"addr"`
	Port      int    `json:"port"`
	DB        string `json:"db"`
	TableFile string `json:"tablefile"` // 表的配置文件
}

Jump to

Keyboard shortcuts

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