db

package
v0.0.0-...-561d2ec Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2020 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewMySQL

func NewMySQL(opts ...Option) (*sql.DB, bool, error)

NewMySQL 创建MySQL数据库实例

Types

type DB

type DB struct {
	*gorp.DbMap
}

DB 数据库

func NewMySQLWithDB

func NewMySQLWithDB(db *sql.DB, trace bool) *DB

NewMySQLWithDB 创建DB

func (*DB) Close

func (m *DB) Close() error

Close 关闭数据库连接

func (*DB) DeleteByPK

func (m *DB) DeleteByPK(table string, pk M) (int64, error)

DeleteByPK 删除表数据

func (*DB) DeleteByPKWithTran

func (m *DB) DeleteByPKWithTran(tran *gorp.Transaction, table string, pk M) (int64, error)

DeleteByPKWithTran 使用事物删除表数据

func (*DB) DeleteSQL

func (m *DB) DeleteSQL(table string, pk M) (string, []interface{})

DeleteSQL 获取删除SQL

func (*DB) In

func (m *DB) In(query string, args ...interface{}) (string, []interface{}, error)

In 组织带有IN查询的SQL

func (*DB) InsertM

func (m *DB) InsertM(table string, info M) (int64, error)

InsertM 插入数据

func (*DB) InsertMWithTran

func (m *DB) InsertMWithTran(tran *gorp.Transaction, table string, info M) (int64, error)

InsertMWithTran 使用事物插入数据

func (*DB) InsertSQL

func (m *DB) InsertSQL(table string, info M) (string, []interface{})

InsertSQL 获取插入SQL

func (*DB) UpdateByPK

func (m *DB) UpdateByPK(table string, pk, info M) (int64, error)

UpdateByPK 更新表数据

func (*DB) UpdateByPKWithTran

func (m *DB) UpdateByPKWithTran(tran *gorp.Transaction, table string, pk, info M) (int64, error)

UpdateByPKWithTran 使用事物更新表数据

func (*DB) UpdateSQL

func (m *DB) UpdateSQL(table string, pk, info M) (string, []interface{})

UpdateSQL 获取更新SQL

type M

type M map[string]interface{}

M 定义字典

type Option

type Option func(*options)

Option 配置项

func SetDSN

func SetDSN(dsn string) Option

SetDSN 设置连接串

func SetMaxIdleConns

func SetMaxIdleConns(maxIdleConns int) Option

SetMaxIdleConns 设置空闲连接池中的最大连接数

func SetMaxLifetime

func SetMaxLifetime(maxLifetime time.Duration) Option

SetMaxLifetime 设置连接可以被重新使用的最大时间量

func SetMaxOpenConns

func SetMaxOpenConns(maxOpenConns int) Option

SetMaxOpenConns 设置打开连接到数据库的最大数量

func SetTrace

func SetTrace(t bool) Option

SetTrace 设置追踪调试

Jump to

Keyboard shortcuts

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