vsql

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 7, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const DriverName = "vsql"

Variables

This section is empty.

Functions

func RegisterDB

func RegisterDB(name string, db DBOnlyCtx)

Types

type ColumnType

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

ColumnType interface off sql.ColumnType

type Conn

type Conn interface {
	BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
	Close() error
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	PingContext(ctx context.Context) error
	PrepareContext(ctx context.Context, query string) (Stmt, error)
	QueryContext(ctx context.Context, query string, args ...any) (Rows, error)
	QueryRowContext(ctx context.Context, query string, args ...any) Row
	Raw(f func(driverConn any) error) (err error)
}

Conn interface off sql.Conn

func NewConn

func NewConn(raw *sql.Conn) Conn

type DB

type DB interface {
	Begin() (Tx, error)
	BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
	Close() error
	Conn(ctx context.Context) (Conn, error)
	Driver() driver.Driver
	Exec(query string, args ...any) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	Ping() error
	PingContext(ctx context.Context) error
	Prepare(query string) (Stmt, error)
	PrepareContext(ctx context.Context, query string) (Stmt, error)
	Query(query string, args ...any) (Rows, error)
	QueryContext(ctx context.Context, query string, args ...any) (Rows, error)
	QueryRow(query string, args ...any) Row
	QueryRowContext(ctx context.Context, query string, args ...any) Row
	SetConnMaxIdleTime(d time.Duration)
	SetConnMaxLifetime(d time.Duration)
	SetMaxIdleConns(n int)
	SetMaxOpenConns(n int)
	Stats() sql.DBStats
}

DB interface off sql.DB

func NewDB

func NewDB(d *sql.DB) DB

NewDB 将 *sql.DB 转换为一个 interface DB

type DBOnlyCtx

type DBOnlyCtx interface {
	BeginTx(ctx context.Context, opts *sql.TxOptions) (Tx, error)
	PrepareContext(ctx context.Context, query string) (Stmt, error)
	QueryContext(ctx context.Context, query string, args ...any) (Rows, error)
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	PingContext(ctx context.Context) error
	Close() error
}

func NewDBOnlyCtx

func NewDBOnlyCtx(raw DBRawOnlyCtx) DBOnlyCtx

type DBRawOnlyCtx

type DBRawOnlyCtx interface {
	BeginTx(ctx context.Context, opts *sql.TxOptions) (*sql.Tx, error)
	PrepareContext(ctx context.Context, query string) (*sql.Stmt, error)
	QueryContext(ctx context.Context, query string, args ...any) (*sql.Rows, error)
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	PingContext(ctx context.Context) error
	Close() error
}

type Row

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

Row interface off sql.Row

type Rows

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

Rows interface off sql.Rows

func NewRows

func NewRows(raw *sql.Rows) Rows

type Stmt

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

Stmt interface off sql.Stmt

func NewStmt

func NewStmt(raw *sql.Stmt) Stmt

type Tx

type Tx interface {
	Commit() error
	Exec(query string, args ...any) (sql.Result, error)
	ExecContext(ctx context.Context, query string, args ...any) (sql.Result, error)
	Prepare(query string) (Stmt, error)
	PrepareContext(ctx context.Context, query string) (Stmt, error)
	Query(query string, args ...any) (Rows, error)
	QueryContext(ctx context.Context, query string, args ...any) (Rows, error)
	QueryRow(query string, args ...any) Row
	QueryRowContext(ctx context.Context, query string, args ...any) Row
	Rollback() error
	Stmt(stmt Stmt) Stmt
	StmtContext(ctx context.Context, stmt Stmt) Stmt
}

Tx interface off sql.Tx

func NewTx

func NewTx(raw *sql.Tx) Tx

Jump to

Keyboard shortcuts

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