db

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: May 13, 2025 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTables

func CreateTables(ddl string) error

func Get

func Get(dest interface{}, query string, args ...interface{}) error

func InitializeDB added in v1.0.1

func InitializeDB(config *Config) error

func MustExec

func MustExec(query string, args ...interface{}) sql.Result

func NamedExec

func NamedExec(query string, arg interface{}) (sql.Result, error)

func NamedInsert

func NamedInsert(query string, arg interface{}) (int64, error)

NamedInsert execute insert statement, return last insert id and error

func NamedQuery

func NamedQuery(query string, arg interface{}) (*sqlx.Rows, error)

func NamedUpdate

func NamedUpdate(query string, arg interface{}) (int64, error)

NamedUpdate execute update statement, return affected row count and error

func Query

func Query(query string, args ...interface{}) (*sqlx.Rows, error)

func Select

func Select(dest interface{}, query string, args ...interface{}) error

Types

type Config added in v1.0.1

type Config struct {
	Type     string         `yaml:"type"`
	Addr     string         `yaml:"addr"`
	Username string         `yaml:"username"`
	Password string         `yaml:"password"`
	DBName   string         `yaml:"dbName"`
	Pool     ConnectionPool `yaml:"pool"`
}

type ConnectionPool added in v1.0.1

type ConnectionPool struct {
	MaxIdleConns    int `yaml:"maxIdleConns"`
	MaxOpenConns    int `yaml:"maxOpenConns"`
	ConnMaxLifetime int `yaml:"connMaxLifetime"`
	ConnMaxIdleTime int `yaml:"connMaxIdleTime"`
}

type Driver added in v1.0.1

type Driver func(config *Config) (ddl string, db *sqlx.DB, err error)

Jump to

Keyboard shortcuts

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