database

package
v0.0.0-...-f3c68be Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2022 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// DB : for the database at the global space
	DB *pgx.Conn
	// ReaderConnectionString ...
	ReaderConnectionString string
	// WriterConnectionString ...
	WriterConnectionString string
)

Functions

func SetConnectionStrings

func SetConnectionStrings()

SetConnectionStrings ...

Types

type DBHandler

type DBHandler struct {
	DatabaseService DbIface
}

DBHandler provides the class implementation for DbIface interface

func DBNewHandler

func DBNewHandler() *DBHandler

DBNewHandler ...

func (DBHandler) CreateConnection

func (dbService DBHandler) CreateConnection(connectionString string) (*pgx.Conn, error)

CreateConnection : Creates the Connection

func (DBHandler) DbClose

func (dbService DBHandler) DbClose()

DbClose : Close the DB connectivity.

func (DBHandler) DbExecuteScalar

func (dbService DBHandler) DbExecuteScalar(query string, args ...interface{}) (pgx.Rows, error)

DbExecuteScalar : To insert/update records.

func (DBHandler) DbExecuteScalarReturningID

func (dbService DBHandler) DbExecuteScalarReturningID(query string, args ...interface{}) (int, error)

DbExecuteScalarReturningID : To insert/update records returns ids.

func (DBHandler) DbQuery

func (dbService DBHandler) DbQuery(query string, responseRowID *int, args ...interface{}) error

DbQuery : To insert/update records.

func (DBHandler) InitDbReader

func (dbService DBHandler) InitDbReader() (*pgx.Conn, error)

InitDbReader : for the database at the global space

func (DBHandler) InitDbWriter

func (dbService DBHandler) InitDbWriter() (*pgx.Conn, error)

InitDbWriter : for the database at the global space

func (DBHandler) TxBegin

func (dbService DBHandler) TxBegin() (pgx.Tx, error)

TxBegin : To begin transaction.

func (DBHandler) TxComplete

func (dbService DBHandler) TxComplete(tx pgx.Tx) error

TxComplete : Save Changes to the Database.

func (DBHandler) TxCreateTempTable

func (dbService DBHandler) TxCreateTempTable(tx pgx.Tx, tblName string, sql string) (*pgconn.StatementDescription, error)

TxCreateTempTable : To execute a query and fetch rows. This will typically perform an insert & select (or) a plain select.

func (DBHandler) TxQuery

func (dbService DBHandler) TxQuery(tx pgx.Tx, query string) (pgx.Rows, error)

TxQuery : To execute a query and fetch rows. This will typically perform an insert & select (or) a plain select.

type DbIface

type DbIface interface {
	DbExecuteScalar(query string, args ...interface{}) (pgx.Rows, error)
	DbQuery(query string, responseRowID *int, args ...interface{}) error
	DbExecuteScalarReturningID(query string, args ...interface{}) (int, error)
	DbClose()
	TxBegin() (pgx.Tx, error)
	TxQuery(tx pgx.Tx, query string) (pgx.Rows, error)
	TxComplete(tx pgx.Tx) error
	TxCreateTempTable(tx pgx.Tx, tblName string, sql string) (*pgconn.StatementDescription, error)
}

DbIface exposes db interconnection methods

Jump to

Keyboard shortcuts

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