database

package
v0.3.8 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2024 License: GPL-3.0 Imports: 6 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoRecordFound     = errors.New("record not found")
	ErrCouldNotBeCreated = errors.New("could not be created in DB")
)

Functions

func GetErrorF

func GetErrorF(errMsg string, err error) error

Types

type DB

type DB interface {
	ExecActionQuery(sql string, arguments ...interface{}) (rowsAffected int, err error)
	Insert(sql string, arguments ...interface{}) (lastInsertId int, err error)
	GetQueryInt(sql string, arguments ...interface{}) (result int, err error)
	GetQueryBool(sql string, arguments ...interface{}) (result bool, err error)
	GetQueryString(sql string, arguments ...interface{}) (result string, err error)
	GetVersion() (result string, err error)
	GetPGConn() (Conn *pgxpool.Pool, err error)
	DoesTableExist(schema, table string) (exist bool)
	Close()
}

DB is the interface for a simple table store.

func GetInstance

func GetInstance(dbDriver, dbConnectionString string, maxConnectionCount int, log golog.MyLogger) (DB, error)

GetInstance with appropriate driver

type PgxDB

type PgxDB struct {
	Conn *pgxpool.Pool
	// contains filtered or unexported fields
}

func (*PgxDB) Close

func (db *PgxDB) Close()

Close is a postgres helper function to close the connection to the database

func (*PgxDB) DoesTableExist added in v0.0.5

func (db *PgxDB) DoesTableExist(schema, table string) (exist bool)

func (*PgxDB) ExecActionQuery

func (db *PgxDB) ExecActionQuery(sql string, arguments ...interface{}) (rowsAffected int, err error)

ExecActionQuery is a postgres helper function for an action query, returning the numbers of rows affected

func (*PgxDB) GetPGConn added in v0.0.3

func (db *PgxDB) GetPGConn() (Conn *pgxpool.Pool, err error)

func (*PgxDB) GetQueryBool

func (db *PgxDB) GetQueryBool(sql string, arguments ...interface{}) (result bool, err error)

GetQueryBool is a postgres helper function for a query expecting an integer result

func (*PgxDB) GetQueryInt

func (db *PgxDB) GetQueryInt(sql string, arguments ...interface{}) (result int, err error)

GetQueryInt is a postgres helper function for a query expecting an integer result

func (*PgxDB) GetQueryString

func (db *PgxDB) GetQueryString(sql string, arguments ...interface{}) (result string, err error)

func (*PgxDB) GetVersion

func (db *PgxDB) GetVersion() (result string, err error)

func (*PgxDB) Insert

func (db *PgxDB) Insert(sql string, arguments ...interface{}) (lastInsertId int, err error)

Jump to

Keyboard shortcuts

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