postgresql

package
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: May 11, 2020 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DRIVER               = "postgres"
	ErrorNoConfiguration = "No configuration given"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type PostgresSQL

type PostgresSQL struct {
	Db *sql.DB
	// contains filtered or unexported fields
}

PostgresSQL represents postgresql database

func New

NewPostgresSQL create new instance of PostgresSQL

func (*PostgresSQL) Begin

Begin starts a transaction. The default isolation level is dependent on the driver.

func (*PostgresSQL) Close

func (db *PostgresSQL) Close() error

Close closes the database and prevents new queries from starting. Close then waits for all queries that have started processing on the server to finish.

It is rare to Close a DB, as the DB handle is meant to be long-lived and shared between many goroutines.

func (*PostgresSQL) Exec

func (db *PostgresSQL) Exec(
	query string,
	args ...interface{},
) (sql.Result, error)

func (*PostgresSQL) ExecContext

func (db *PostgresSQL) ExecContext(
	ctx context.Context,
	query string,
	args ...interface{},
) (sql.Result, error)

ExecContext executes a query without returning any rows. The args are for any placeholder parameters in the query.

func (*PostgresSQL) Open

func (db *PostgresSQL) Open() error

Open connection to psql and set:

  • amount of max open connections
  • amount of max idle connections
  • max lifetime of connection

return result of ping

func (*PostgresSQL) PingContext

func (db *PostgresSQL) PingContext(
	ctx context.Context,
) error

PingContext verifies a connection to the database is still alive, establishing a connection if necessary.

func (*PostgresSQL) Query

func (db *PostgresSQL) Query(
	query string,
	args ...interface{},
) (*sql.Rows, error)

func (*PostgresSQL) QueryContext

func (db *PostgresSQL) QueryContext(
	ctx context.Context,
	query string,
	args ...interface{},
) (*sql.Rows, error)

QueryContext executes a query that returns rows, typically a SELECT. The args are for any placeholder parameters in the query.

func (*PostgresSQL) QueryRow

func (db *PostgresSQL) QueryRow(
	query string,
	args ...interface{}) *sql.Row

func (*PostgresSQL) QueryRowContext

func (db *PostgresSQL) QueryRowContext(
	ctx context.Context,
	query string,
	args ...interface{}) *sql.Row

QueryRowContext executes a query that is expected to return at most one row. QueryRowContext always returns a non-nil value. Errors are deferred until Row's Scan method is called. If the query selects no rows, the *Row's Scan will return ErrNoRows. Otherwise, the *Row's Scan scans the first selected row and discards the rest.

func (*PostgresSQL) Run

func (db *PostgresSQL) Run() error

Jump to

Keyboard shortcuts

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