db

package module
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: Apache-2.0 Imports: 3 Imported by: 10 modules, 11 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

db

定义数据库执行器基础方法接口

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BaseExecutor

type BaseExecutor interface {
	PrepareContext(ctx context.Context, query string) (Stmt, error)

	ExecContext(ctx context.Context, query string, args ...any) (Result, error)

	QueryContext(ctx context.Context, query string, args ...any) (Rows, error)

	QueryRowContext(ctx context.Context, query string, args ...any) Row
}

type ColumnType added in v1.2.0

type ColumnType interface {
	Name() string
	Nullable() (nullable, ok bool)
	ScanType() reflect.Type
	DatabaseTypeName() string
	DecimalSize() (precision, scale int64, ok bool)
	Length() (length int64, ok bool)
}

type Executor

type Executor interface {
	BaseExecutor

	BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
}

type Result added in v1.2.0

type Result interface {
	// LastInsertId returns the integer generated by the database
	// in response to a command. Typically this will be from an
	// "auto increment" column when inserting a new row. Not all
	// databases support this feature, and the syntax of such
	// statements varies.
	LastInsertId() (int64, error)

	// RowsAffected returns the number of rows affected by an
	// update, insert, or delete. Not every database or database
	// driver may support this.
	RowsAffected() (int64, error)
}

A Result summarizes an executed SQL command.

type Row

type Row interface {
	Scan(dest ...any) error
}

type Rows

type Rows interface {
	ColumnTypes() ([]ColumnType, error)
	Columns() ([]string, error)
	Err() error
	Next() bool
	NextResultSet() bool
	Close() error
	Scan(dest ...any) error
}

type Stmt

type Stmt interface {
	Close() error
	ExecContext(ctx context.Context, args ...any) (Result, error)
	QueryContext(ctx context.Context, args ...any) (Rows, error)
	QueryRowContext(ctx context.Context, args ...any) Row
}

type Tx

type Tx interface {
	BaseExecutor

	Commit() error
	Rollback() error
	StmtContext(ctx context.Context, stmt Stmt) Stmt
}

Jump to

Keyboard shortcuts

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