sqldb

package
v1.9.55 Latest Latest
Warning

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

Go to latest
Published: Jan 10, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	FlagNameDbPingTimeout  = "db.ping.timeout"
	FlagNameDbQueryTimeout = "db.query.timeout"
	FlagNameDbMaxIdle      = "db.max.idle"
	FlagNameDbMaxOpen      = "db.max.open"
	FlagNameDbMaxLifetime  = "db.max.lifetime"
)

Variables

View Source
var (
	FlagDbPingTimeout  = common.SystemFlagInt(FlagNameDbPingTimeout, 3*1000, "Database ping timeout")
	FlagDbQueryTimeout = common.SystemFlagInt(FlagNameDbQueryTimeout, 120*1000, "Database query timeout")
	FlagDbMaxIdle      = common.SystemFlagInt(FlagNameDbMaxIdle, 0, "Database max idle connections")
	FlagMaxOpen        = common.SystemFlagInt(FlagNameDbMaxOpen, 0, "Database max open connections")
	FlagMaxLifetime    = common.SystemFlagInt(FlagNameDbMaxLifetime, 0, "Database connection max lifetime")
)

Functions

This section is empty.

Types

type Field

type Field struct {
	Value  any  `json:"value"`
	IsNull bool `json:"isnull"`
}

func (Field) String

func (f Field) String() string

type Resultset

type Resultset struct {
	ColumnNames []string
	ColumnTypes []*sql.ColumnType
	RowCount    int
	Rows        any
}

func (*Resultset) FieldByIndex

func (rs *Resultset) FieldByIndex(row int, col int) Field

func (*Resultset) FieldByName

func (rs *Resultset) FieldByName(row int, fieldName string) Field

type ResultsetFunc

type ResultsetFunc func(rs *Resultset) error

type SqlDb

type SqlDb struct {
	Driver string
	DSN    string
	// contains filtered or unexported fields
}

func NewSqlDb

func NewSqlDb(driver, dsn string) (*SqlDb, error)

func (*SqlDb) Begin

func (sqlDb *SqlDb) Begin() error

func (*SqlDb) Close

func (sqlDb *SqlDb) Close() error

func (*SqlDb) Commit

func (sqlDb *SqlDb) Commit() error

func (*SqlDb) Execute

func (sqlDb *SqlDb) Execute(sqlcmd string, args ...any) (int64, error)

func (*SqlDb) Health

func (sqlDb *SqlDb) Health() error

func (*SqlDb) Init

func (sqlDb *SqlDb) Init(driver, dsn string) error

func (*SqlDb) Query

func (sqlDb *SqlDb) Query(sqlcmd string, args ...any) (*Resultset, error)

func (*SqlDb) QueryPaged

func (sqlDb *SqlDb) QueryPaged(fn ResultsetFunc, pageRowCount int, sqlcmd string, args ...any) (int, error)

func (*SqlDb) Rollback

func (sqlDb *SqlDb) Rollback() error

Jump to

Keyboard shortcuts

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