mysql

package
v1.3.18 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2022 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InsertCompiler

func InsertCompiler(ctx context.Context, client Client, builder *InsertBuilder, data map[string]interface{}, hasLog ...bool) string

func InsertWithBuilder

func InsertWithBuilder(ctx context.Context, client Client, builder *InsertBuilder, data map[string]interface{}, hasLog ...bool) error

InsertWithBuilder 传入一个 SQLBuilder 并执行 QueryContext

func QueryCompiler

func QueryCompiler(ctx context.Context, client Client, builder *SelectBuilder) string

func QueryWithBuilder

func QueryWithBuilder(ctx context.Context, client Client, builder *SelectBuilder, data interface{}) error

QueryWithBuilder 传入一个 SQLBuilder 并执行 QueryContext

Types

type Client

type Client interface {
	DbName() string
	DbDriver() string
	DbIp() string
	DbPort() string
	UserName() string
	UserPassword() string
	DbPool() DbPool
	SetDbName(str string)
	SetDbDriver(str string)
	SetDbIp(str string)
	SetDbPort(str string)
	SetUserName(str string)
	SetUserPassword(str string)
	SetDbPool(dp DbPool)
	Query(ctx context.Context, tableName string, where map[string]interface{}, columns []string, data interface{}) error
	Insert(ctx context.Context, tableName string, data map[string]interface{}) error
	InsertNoLog(ctx context.Context, tableName string, data map[string]interface{}) error
}

func New

func New(config *Config) Client

func NewDefault

func NewDefault() Client

type Config

type Config struct {
	Username string // 账号名
	Password string // 密码
	DbName   string // 数据库名称
	DbDriver string // 驱动名称
	Host     string
	Port     string
}

Config 配置

func DefaultDbConf

func DefaultDbConf() *Config

type DbPool

type DbPool interface {
	Connect(client Client) (*sqlx.DB, error)
	GetDb(db string) *sqlx.DB
}

func DefaultDbPool

func DefaultDbPool() DbPool

type InsertBuilder

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

InsertBuilder 默认的select sql builder

func NewInsertBuilder

func NewInsertBuilder(table string) *InsertBuilder

type SelectBuilder

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

SelectBuilder 默认的select sql builder

func NewSelectBuilder

func NewSelectBuilder(table string, where map[string]interface{}, fields []string) *SelectBuilder

Jump to

Keyboard shortcuts

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