mysql

package
v0.0.0-...-b1b21d8 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: LGPL-3.0 Imports: 9 Imported by: 0

README

功能概述 sql 操作的封装

  • 简化mysql 操作的
  • mysql 数据类型自动映射

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Client

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

func NewClient

func NewClient(ctx context.Context, options ...ClientOption) (*Client, error)

func (*Client) Close

func (obj *Client) Close() error

关闭客户端

func (*Client) Exec

func (obj *Client) Exec(ctx context.Context, query string, args ...any) (*Result, error)

执行

func (*Client) Finds

func (obj *Client) Finds(ctx context.Context, query string, args ...any) (*Rows, error)

finds ? is args

func (*Client) Insert

func (obj *Client) Insert(ctx context.Context, table string, datas ...any) error

insert ? is args

type ClientOption

type ClientOption struct {
	DriverName  string //驱动名称
	OpenUrl     string //自定义的uri
	Usr         string //用户名
	Pwd         string //密码
	Host        string
	Port        int
	DbName      string            //数据库
	Protocol    string            //协议
	MaxConns    int               //最大连接数
	MaxLifeTime time.Duration     //最大活跃数
	Params      map[string]string //附加参数
}

type Result

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

func (*Result) LastInsertId

func (obj *Result) LastInsertId() (int64, error)

新插入的列

func (*Result) RowsAffected

func (obj *Result) RowsAffected() (int64, error)

受影响的行数

type Rows

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

func (*Rows) Close

func (obj *Rows) Close() error

关闭游标

func (*Rows) Data

func (obj *Rows) Data() map[string]any

返回游标的数据

func (*Rows) Next

func (obj *Rows) Next() bool

是否有下一个数据

Jump to

Keyboard shortcuts

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