mysql

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2024 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Factory

type Factory struct {
	*sql.DB
}

Factory 会话工厂

func New

func New(driverName, dataSourseName string) (*Factory, error)

New 创建一个会话工厂

func (*Factory) GetSession

func (sf *Factory) GetSession() *Session

GetSession 获取一个Session

type Session

type Session struct {
	DB *sql.DB // 原生db
	// contains filtered or unexported fields
}

Session 会话

func (*Session) Begin

func (s *Session) Begin() error

Begin 开启事务

func (*Session) Commit

func (s *Session) Commit() error

Commit 提交事务

func (*Session) Exec

func (s *Session) Exec(query string, args ...interface{}) (sql.Result, error)

Exec 执行sql语句,如果已经开启事务,就以事务方式执行,如果没有开启事务,就以非事务方式执行

func (*Session) Prepare

func (s *Session) Prepare(query string) (*sql.Stmt, error)

Prepare 预执行,如果已经开启事务,就以事务方式执行,如果没有开启事务,就以非事务方式执行

func (*Session) Query

func (s *Session) Query(query string, args ...interface{}) (*sql.Rows, error)

Query 查询数据,如果已经开启事务,就以事务方式执行,如果没有开启事务,就以非事务方式执行

func (*Session) QueryRow

func (s *Session) QueryRow(query string, args ...interface{}) *sql.Row

QueryRow 如果已经开启事务,就以事务方式执行,如果没有开启事务,就以非事务方式执行

func (*Session) Rollback

func (s *Session) Rollback() error

Rollback 回滚事务

Jump to

Keyboard shortcuts

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