sql

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Conn

type Conn struct {
	ExecQuerier
}

func (Conn) Exec

func (c Conn) Exec(ctx context.Context, query string, args []any, v any) error

Exec dialect.ExecQuerier.Exec的实现

func (Conn) Query

func (c Conn) Query(ctx context.Context, query string, args []any, v *dialect.Rows) error

Query dialect.ExecQuerier.Query的实现

type Driver

type Driver struct {
	Conn
	// contains filtered or unexported fields
}

func NewDriver

func NewDriver(driver dialect.DbDriver, c Conn) *Driver

NewDriver 创建一个新的数据库驱动。

func (*Driver) BeginTx

func (d *Driver) BeginTx(ctx context.Context, opts *TxOptions) (dialect.Tx, error)

BeginTx 开始一个事务。

func (*Driver) Close

func (d *Driver) Close() error

Close 关闭数据库连接。

func (Driver) DB

func (d Driver) DB() *sql.DB

DB 返回数据库连接。

func (Driver) Dialect

func (d Driver) Dialect() dialect.DbDriver

Dialect 返回数据库类型。

func (*Driver) Tx

func (d *Driver) Tx(context.Context) (dialect.Tx, error)

Tx 返回一个事务。

type ExecQuerier

type ExecQuerier interface {
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) *sql.Row
}

type Tx

type Tx struct {
	Conn
	driver.Tx
}

type TxOptions

type TxOptions = sql.TxOptions

Jump to

Keyboard shortcuts

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