pgdb

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2019 License: MIT Imports: 6 Imported by: 0

README

go-pgdb-lib

Postgres database support functions

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DbConn

type DbConn struct {
	Hostname string
	Port     string
	Name     string
	Username string
	Password string
}

DBConn database connection details

func (*DbConn) Close

func (dbConn *DbConn) Close(db *sql.DB) error

Close closes the connection with the database The method return an error if something goes wrong

func (*DbConn) ClosureError added in v1.0.1

func (dbConn *DbConn) ClosureError(err error) error

CloseError returns a formatted database disconnection error

func (*DbConn) Connect

func (dbConn *DbConn) Connect() (*sql.DB, error)

Connect establishes a connection with the database and validates the connection The method return the db connection or an error if something goes wrong

func (*DbConn) ConnectionError added in v1.0.1

func (dbConn *DbConn) ConnectionError(err error) error

ConnectionError returns a formatted database connection error

func (*DbConn) Exec

func (dbConn *DbConn) Exec(query string) error

Exec executes a query on the database The method return an error if something goes wrong

func (*DbConn) GetConn

func (dbConn *DbConn) GetConn() DbConn

getConn gets the database connection details from environment variables If the documented environment variables are not set the method return default values

func (*DbConn) GetConnString

func (dbConn *DbConn) GetConnString() string

GetDBConnString gets the database connection details and returns the database connection string

func (*DbConn) QueryExecError added in v1.0.1

func (dbConn *DbConn) QueryExecError(err error) error

QueryExecError returns a formatted database query execution error

func (*DbConn) RowScanError added in v1.0.1

func (dbConn *DbConn) RowScanError(err error) error

RowScanError returns a formatted database error while scanning rows

type Enum

type Enum struct {
	Name   string
	Values []string
}

Enum represents a Enum type in the database

func (*Enum) Create

func (e *Enum) Create() error

Create creates a new enum type in the database The method returns an error if something goes wrong

func (*Enum) Delete

func (e *Enum) Delete() error

Delete removes the enum type from the database The method returns an error if something goes wrong

func (*Enum) Exists

func (e *Enum) Exists() (bool, error)

Exists checks if a enum type already exists or not in the database The method returns a boolean value and an error depending on the result

func (*Enum) Get

func (e *Enum) Get() error

Get returns a list of enum type values The method returns the values of a enum or an error

func (*Enum) IsValidEnumName added in v1.0.3

func (e *Enum) IsValidEnumName() error

IsValidEnumName checks if enum name is not empty The method return an error if enum name is a empty value

func (*Enum) Update

func (e *Enum) Update() error

Add updates the enum type in the database The method returns an error if something goes wrong

type Table

type Table struct {
	Name    string
	Columns []TableColumn
}

func (*Table) Create

func (t *Table) Create() error

Create creates a new table in the database The method returns an error if something goes wrong

func (*Table) Delete

func (t *Table) Delete() error

Delete drops the table from tha database The method returns an error if something goes wrong

func (*Table) Exists

func (t *Table) Exists() (bool, error)

Exists checks if a table already exists The method returns a boolean value or an error if something goes wrong

func (*Table) GetQuery

func (t *Table) GetQuery() string

GetQuery creates and returns a SQL table query which would be used to create a table in the database

type TableColumn

type TableColumn struct {
	Name        string
	DataType    string
	Constraints []string
}

Jump to

Keyboard shortcuts

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