sqldb

package
v1.0.39 Latest Latest
Warning

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

Go to latest
Published: Jul 7, 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 FieldBool

type FieldBool struct {
	sql.NullBool
}

func NewFieldBool

func NewFieldBool(v ...bool) FieldBool

func (*FieldBool) Bool

func (c *FieldBool) Bool() bool

func (FieldBool) MarshalJSON

func (c FieldBool) MarshalJSON() ([]byte, error)

func (*FieldBool) SetBool

func (c *FieldBool) SetBool(v bool)

func (*FieldBool) SetNull

func (c *FieldBool) SetNull()

func (FieldBool) String

func (c FieldBool) String() string

func (*FieldBool) UnmarshalJSON

func (c *FieldBool) UnmarshalJSON(data []byte) error

type FieldInt64

type FieldInt64 struct {
	sql.NullInt64
}

func NewFieldInt64

func NewFieldInt64(v ...int64) FieldInt64

func (*FieldInt64) Int64

func (c *FieldInt64) Int64() int64

func (FieldInt64) MarshalJSON

func (c FieldInt64) MarshalJSON() ([]byte, error)

func (*FieldInt64) SetInt64

func (c *FieldInt64) SetInt64(v int64)

func (*FieldInt64) SetNull

func (c *FieldInt64) SetNull()

func (FieldInt64) String

func (c FieldInt64) String() string

func (*FieldInt64) UnmarshalJSON

func (c *FieldInt64) UnmarshalJSON(data []byte) error

type FieldString

type FieldString struct {
	sql.NullString
}

func NewFieldString

func NewFieldString(v ...string) FieldString

func (*FieldString) GetString

func (c *FieldString) GetString(v string)

func (FieldString) MarshalJSON

func (c FieldString) MarshalJSON() ([]byte, error)

func (*FieldString) SetField

func (c *FieldString) SetField(other FieldString)

func (*FieldString) SetNull

func (c *FieldString) SetNull()

func (*FieldString) SetString

func (c *FieldString) SetString(v string)

func (FieldString) String

func (c FieldString) String() string

func (*FieldString) UnmarshalJSON

func (c *FieldString) UnmarshalJSON(data []byte) error

type FieldTime

type FieldTime struct {
	sql.NullTime
}

func NewFieldTime

func NewFieldTime(v ...time.Time) FieldTime

func (FieldTime) MarshalJSON

func (c FieldTime) MarshalJSON() ([]byte, error)

func (*FieldTime) SetNull

func (c *FieldTime) SetNull()

func (*FieldTime) SetTime

func (c *FieldTime) SetTime(v time.Time)

func (FieldTime) String

func (c FieldTime) String() string

func (*FieldTime) Time

func (c *FieldTime) Time() time.Time

func (*FieldTime) UnmarshalJSON

func (c *FieldTime) UnmarshalJSON(data []byte) error

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) Open

func (sqlDb *SqlDb) Open() 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