database

package
v0.0.0-...-5d16d2b Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: GPL-3.0 Imports: 9 Imported by: 0

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)
	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)
	GetSpatialVersion() (result string, err error)
	DoesTableExist(schema, table string) (exist bool)
	Close()
	IsItSpatial() bool
	GetQueryStringArr(sql string, arguments ...interface{}) (result []string, err error)
}

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

func NewSqlite3DB

func NewSqlite3DB(geopackageFilePath string, log golog.MyLogger) (DB, error)

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

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

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) GetQueryStringArr

func (db *PgxDB) GetQueryStringArr(sql string, arguments ...any) (result []string, err error)

func (*PgxDB) GetSpatialVersion

func (db *PgxDB) GetSpatialVersion() (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)

func (*PgxDB) IsItSpatial

func (db *PgxDB) IsItSpatial() bool

type SQLITE3

type SQLITE3 struct {
	Conn *sql.DB
	// contains filtered or unexported fields
}

SQLITE3 is a struct to hold the connection to a sqlite3 database

func (*SQLITE3) Close

func (db *SQLITE3) Close()

func (*SQLITE3) DoesTableExist

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

func (*SQLITE3) ExecActionQuery

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

func (*SQLITE3) GetQueryBool

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

func (*SQLITE3) GetQueryInt

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

func (*SQLITE3) GetQueryString

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

func (*SQLITE3) GetQueryStringArr

func (db *SQLITE3) GetQueryStringArr(sql string, arguments ...interface{}) (result []string, err error)

func (*SQLITE3) GetSpatialVersion

func (db *SQLITE3) GetSpatialVersion() (result string, err error)

func (*SQLITE3) GetVersion

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

func (*SQLITE3) IsItSpatial

func (db *SQLITE3) IsItSpatial() bool

Jump to

Keyboard shortcuts

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