database

package
v0.9.2 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENGINE_SQLITE   = "sqlite3"
	ENGINE_MYSQL    = "mysql"
	ENGINE_POSTGRES = "postgres"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

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

func NewDatabase

func NewDatabase(cfg *conf.Database) (*Database, error)

func NewDatabaseWithConnection

func NewDatabaseWithConnection(db *sql.DB) Database

func (*Database) Close

func (db *Database) Close() error

func (*Database) Exec

func (db *Database) Exec(sql string, data ...interface{}) error

func (*Database) GetDatabase

func (db *Database) GetDatabase() *sql.DB

func (*Database) GetLastInsertId

func (db *Database) GetLastInsertId() uint64

func (*Database) GetName added in v0.6.2

func (db *Database) GetName() string

func (*Database) GetOne

func (db *Database) GetOne(sql string, data ...interface{}) ([]byte, error)

func (*Database) GetRecord

func (db *Database) GetRecord(sqlString string, data ...interface{}) (map[string]interface{}, error)

func (*Database) GetRecords

func (db *Database) GetRecords(sqlString string, data ...interface{}) ([]map[string]interface{}, error)

func (*Database) GetResult

func (db *Database) GetResult() (sql.Result, error)

func (*Database) GetStmt

func (db *Database) GetStmt(sql string) (*sql.Stmt, error)

func (*Database) Insert

func (db *Database) Insert(tableName string, data map[string]interface{}) error

func (*Database) IsConnected

func (db *Database) IsConnected() bool

func (*Database) IsMySQL

func (db *Database) IsMySQL() bool

func (*Database) IsPostgres

func (db *Database) IsPostgres() bool

func (*Database) IsSQLite

func (db *Database) IsSQLite() bool

func (*Database) SetEngine added in v0.7.12

func (db *Database) SetEngine(engine string)

func (*Database) Update

func (db *Database) Update(tableName string, data map[string]interface{}) error

type IDatabase

type IDatabase interface {
	Exec(sql string, data ...interface{}) error
	GetOne(sql string, data ...interface{}) ([]byte, error)
	GetRecord(sql string, data ...interface{}) (map[string]interface{}, error)
	GetRecords(sql string, data ...interface{}) ([]map[string]interface{}, error)
	Insert(tableName string, data map[string]interface{}) error
	Update(tableName string, data map[string]interface{}) error
	IsConnected() bool
	IsSQLite() bool
	IsMySQL() bool
	IsPostgres() bool
	GetLastInsertId() uint64
	GetResult() (sql.Result, error)
	GetDatabase() *sql.DB
	GetName() string
	SetEngine(engine string)
	// contains filtered or unexported methods
}

type Pool added in v0.6.2

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

func NewPool added in v0.6.2

func NewPool() *Pool

func (*Pool) AddConnection added in v0.6.2

func (p *Pool) AddConnection(name string, conn *Database) error

func (*Pool) GetConnection added in v0.6.2

func (p *Pool) GetConnection(name string) *Database

func (*Pool) IsConnected added in v0.6.3

func (p *Pool) IsConnected(name string) bool

func (*Pool) RemoveConnection added in v0.6.2

func (p *Pool) RemoveConnection(name string) error

Jump to

Keyboard shortcuts

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