db

package
v0.0.0-...-432d548 Latest Latest
Warning

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

Go to latest
Published: Feb 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const ExternalProto = "ext"

ExternalProto ...

Variables

This section is empty.

Functions

func InitDbGormConnection

func InitDbGormConnection(connStr string, poolSize int, dns utils.DNSClient) (*gorm.DB, error)

InitDbGormConnection ...

Types

type Config

type Config struct {
	User    string
	Passwd  string
	Net     string
	Addr    string
	DBName  string
	Timeout time.Duration
	Params  map[string]string
}

Config ...

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB ...

func NewDB

func NewDB() *DB

NewDB ...

func NewDBMock

func NewDBMock(impl *sql.DB) *DB

NewDBMock ...

func (*DB) Close

func (d *DB) Close()

Close ...

func (*DB) Exec

func (d *DB) Exec(sql string, value ...interface{}) error

Exec ...

func (*DB) ExecWithTX

func (d *DB) ExecWithTX(iLevel sql.IsolationLevel, sqlStr string, args ...interface{}) error

ExecWithTX exec sql in transaction

func (*DB) Mock

func (d *DB) Mock(db *sql.DB)

Mock ...

func (*DB) Open

func (d *DB) Open(config *Config) error

Open ...

func (*DB) OpenWithDSN

func (d *DB) OpenWithDSN(dsn string) error

OpenWithDSN open db connection with dsn string

func (*DB) Query

func (d *DB) Query(mapper func(row Row) (interface{}, error), sql string, args ...interface{}) ([]interface{}, error)

Query ...

func (*DB) QueryMap

func (d *DB) QueryMap(conv func(i interface{}) interface{}, sql string, args ...interface{}) ([]map[string]interface{}, error)

QueryMap ...

func (*DB) QueryRow

func (d *DB) QueryRow(mapper func(row Row) (interface{}, error), sql string, args ...interface{}) (interface{}, error)

QueryRow ...

func (*DB) SetImpl

func (d *DB) SetImpl(db *sql.DB)

SetImpl if necessary, such as tddlx

type Row

type Row interface {
	Scan(args ...interface{}) error
}

Row ...

Jump to

Keyboard shortcuts

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