easysql

package module
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2020 License: MIT Imports: 10 Imported by: 0

README

go report card Build Status Codacy Badge MIT license

EasySQL

Golang贼好用的ORM库,旨在对开发人员友好、轻量、灵活、快捷。

作者(Support)
概况
  • 灵活性极强
  • 日志友好
  • 测试覆盖率100%
  • 开发人员友好
  • SQL统一管理
  • 可扩展性
  • 数据库事物
更新日志
  • V0.0.4 修复若干BUG

  • V0.0.3 事务日志输出日志添加

  • V0.0.2 增加SQL统一管理

  • V0.0.1 增加SQL打印输出

安装
go get -u github.com/hackerfj/easysql
详细文档

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func InitSQL added in v0.0.3

func InitSQL(filePath string) (result map[string]string, err error)

func IsEmpty added in v0.0.5

func IsEmpty(contrast string, call func(isEmpty bool))

Types

type DB

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

func Open

func Open(driverName string, username string, password string, ip string, port string, dbName string) (*DB, error)

Open 初始化创建连接

func (*DB) AutoRefreshSQL added in v0.0.3

func (db *DB) AutoRefreshSQL()

AutoRefreshSQL 自动刷新SQL-无需重启服务 不建议生产环境启用 默认值5S一次

func (*DB) AutoRefreshSQLCustom added in v0.0.3

func (db *DB) AutoRefreshSQLCustom(spec string)

AutoRefreshSQL 自动刷新SQL-无需重启服务 不建议生产环境启用

func (*DB) Begin

func (db *DB) Begin() (*TxDB, error)

Begin transaction begin with default isolation level is dependent

func (*DB) BeginWithIsol

func (db *DB) BeginWithIsol(isolLevel sql.IsolationLevel, readOnly bool) (*TxDB, error)

BeginWithIsol transaction begin with custom isolation level is dependent LevelDefault 默认级别 LevelReadUncommitted 读未提交 LevelReadCommitted 读已提交 LevelWriteCommitted 写已提交 LevelRepeatableRead 可重复读 LevelSnapshot 可读快照 LevelSerializable 可串行化 LevelLinearizable 可线性化

func (*DB) Close

func (db *DB) Close()

Close 关闭连接

func (*DB) Delete

func (db *DB) Delete(query string, args ...interface{}) (int64, error)

Delete operation ,return rows affected

func (*DB) Exec

func (db *DB) Exec(name string, param ...interface{}) (sql.Result, error)

func (*DB) GetRow

func (db *DB) GetRow(name string, param ...interface{}) (map[string]interface{}, error)

func (*DB) GetRows

func (db *DB) GetRows(name string, param ...interface{}) ([]map[string]interface{}, error)

func (*DB) GetVal

func (db *DB) GetVal(name string, param ...interface{}) (interface{}, error)

func (*DB) Insert

func (db *DB) Insert(query string, args ...interface{}) (int64, error)

Insert operation ,return new insert id

func (*DB) InsertMany added in v0.0.3

func (db *DB) InsertMany(tableName string, params []map[string]interface{})

func (*DB) RefreshSQL added in v0.0.3

func (db *DB) RefreshSQL()

RefreshSQL 手动刷新SQL-无需重启服务

func (*DB) SetConnMaxLifetime

func (db *DB) SetConnMaxLifetime(d time.Duration)

SetConnMaxLifetime 设置连接的最大可复用时间。

func (*DB) SetDeBUG

func (db *DB) SetDeBUG(b bool)

SetDeBUG 设置是否开启DEBUG模式

func (*DB) SetMaxIdleConn

func (db *DB) SetMaxIdleConn(n int)

SetMaxIdleConn 设置连接池中的最大闲置连接数。

func (*DB) SetMaxOpenConn

func (db *DB) SetMaxOpenConn(n int)

SetMaxOpenConn 设置数据库的最大连接数量。

func (*DB) SetSQLPath added in v0.0.3

func (db *DB) SetSQLPath(filePath string)

SetSQLPath 设置md的sql文件访问路径

func (*DB) Update

func (db *DB) Update(query string, args ...interface{}) (int64, error)

Update operation ,return rows affected

type TxDB

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

TxDB tx obj

func (*TxDB) Commit

func (txConn *TxDB) Commit() error

Commit transaction commit

func (*TxDB) Delete

func (txConn *TxDB) Delete(query string, args ...interface{}) (int64, error)

Delete Delete operation

func (*TxDB) GetRow

func (txConn *TxDB) GetRow(query string, args ...interface{}) (map[string]interface{}, error)

GetRow get single row data by transaction

func (*TxDB) GetRows

func (txConn *TxDB) GetRows(query string, args ...interface{}) ([]map[string]interface{}, error)

GetResults get multiple rows data by transaction

func (*TxDB) GetVal

func (txConn *TxDB) GetVal(query string, args ...interface{}) (interface{}, error)

GetVal get single value by transaction

func (*TxDB) Insert

func (txConn *TxDB) Insert(query string, args ...interface{}) (int64, error)

Insert Insert operation

func (*TxDB) Rollback

func (txConn *TxDB) Rollback() error

Rollback transaction rollback

func (*TxDB) Update

func (txConn *TxDB) Update(query string, args ...interface{}) (int64, error)

Update Update operation

Jump to

Keyboard shortcuts

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