sql

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 10, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotFound = sql.ErrNoRows

Functions

This section is empty.

Types

type Command

type Command interface {
	Close() error
	Ping(ctx context.Context) error
	In(query string, args ...interface{}) (string, []interface{}, error)
	Rebind(query string) string
	QueryIn(ctx context.Context, name string, query string, args ...interface{}) (*sqlx.Rows, error)
	QueryRow(ctx context.Context, name string, query string, args ...interface{}) (*sqlx.Row, error)
	Query(ctx context.Context, name string, query string, args ...interface{}) (*sqlx.Rows, error)
	NamedQuery(ctx context.Context, name string, query string, arg interface{}) (*sqlx.Rows, error)
	Prepare(ctx context.Context, name string, query string) (CommandStmt, error)

	NamedExec(ctx context.Context, name string, query string, args interface{}) (sql.Result, error)
	Exec(ctx context.Context, name string, query string, args ...interface{}) (sql.Result, error)
	BeginTx(ctx context.Context, name string, opts TxOptions) (CommandTx, error)

	Get(ctx context.Context, name string, query string, dest interface{}, args ...interface{}) error
}

type CommandStmt

type CommandStmt interface {
	Close() error
	Select(name string, dest interface{}, args ...interface{}) error
	Get(name string, dest interface{}, args ...interface{}) error
	QueryRow(name string, args ...interface{}) (*sqlx.Row, error)
	Query(name string, args ...interface{}) (*sqlx.Rows, error)
	Exec(name string, args ...interface{}) (sql.Result, error)
}

type CommandTx

type CommandTx interface {
	Commit() error
	Rollback()
	Rebind(query string) string
	Select(name string, query string, dest interface{}, args ...interface{}) error
	Get(name string, query string, dest interface{}, args ...interface{}) error
	QueryRow(name string, query string, args ...interface{}) (*sqlx.Row, error)
	Query(name string, query string, args ...interface{}) (*sqlx.Rows, error)
	Prepare(name string, query string) (CommandStmt, error)

	NamedExec(name string, query string, args interface{}) (sql.Result, error)
	Exec(name string, query string, args ...interface{}) (sql.Result, error)
	Stmt(name string, stmt *sqlx.Stmt) CommandStmt
}

type Config

type Config struct {
	UseInstrument bool
	LogQuery      bool
	Driver        string
	Name          string
	Leader        ConnConfig
	Follower      ConnConfig
}

type ConnConfig

type ConnConfig struct {
	Host     string
	Port     int
	DB       string
	User     string
	Password string
	SSL      bool
	Schema   string
	Options  ConnOptions
	MockDB   *sql.DB
}

type ConnOptions

type ConnOptions struct {
	MaxLifeTime time.Duration
	MaxIdle     int
	MaxOpen     int
}

type Interface

type Interface interface {
	Leader() Command
	Follower() Command
	Stop()
}

func Init

func Init(cfg Config, log logger.Interface, instr instrument.Interface) Interface

type TxOptions

type TxOptions struct {
	Isolation sql.IsolationLevel
	ReadOnly  bool
}

Jump to

Keyboard shortcuts

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