adapter

package
v0.0.0-...-1ac2cc1 Latest Latest
Warning

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

Go to latest
Published: May 16, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextWithSqlDo

func ContextWithSqlDo(ctx context.Context, db SqlDo) context.Context

func Register

func Register(a Adapter, aliases ...string)

Types

type Adapter

type Adapter interface {
	DB
	DriverName() string
	Dialect() Dialect
	Catalog(ctx context.Context) (*sqlbuilder.Tables, error)
}

func Open

func Open(ctx context.Context, dsn string) (a Adapter, err error)

type Connector

type Connector interface {
	Open(ctx context.Context, dsn *url.URL) (Adapter, error)
}

type DB

type DB interface {
	Exec(ctx context.Context, expr sqlbuilder.SqlExpr) (sql.Result, error)
	Query(ctx context.Context, expr sqlbuilder.SqlExpr) (*sql.Rows, error)
	Transaction(ctx context.Context, action func(ctx context.Context) error) error
	Close() error
}

func Wrap

func Wrap(d *sql.DB, convertErr func(err error) error) DB

type DBSetting

type DBSetting interface {
	SetMaxOpenConns(n int)
	SetMaxIdleConns(n int)
	SetConnMaxLifetime(t time.Duration)
}

type Dialect

type Dialect interface {
	CreateTableIsNotExists(t sqlbuilder.Table) []sqlbuilder.SqlExpr
	DropTable(t sqlbuilder.Table) sqlbuilder.SqlExpr
	TruncateTable(t sqlbuilder.Table) sqlbuilder.SqlExpr

	AddColumn(col sqlbuilder.Column) sqlbuilder.SqlExpr
	RenameColumn(col sqlbuilder.Column, target sqlbuilder.Column) sqlbuilder.SqlExpr
	ModifyColumn(col sqlbuilder.Column, prev sqlbuilder.Column) sqlbuilder.SqlExpr
	DropColumn(col sqlbuilder.Column) sqlbuilder.SqlExpr

	AddIndex(key sqlbuilder.Key) sqlbuilder.SqlExpr
	DropIndex(key sqlbuilder.Key) sqlbuilder.SqlExpr

	DataType(columnDef sqlbuilder.ColumnDef) sqlbuilder.SqlExpr
}

type SqlDo

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

func SqlDoFromContext

func SqlDoFromContext(ctx context.Context) SqlDo

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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