postgrespq

package
v2.1.8 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2023 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Connector

type Connector struct {
	ConnectionString string
}

Connector implements connection.Handler

func (*Connector) Open

Open opens a connection to postgres and returns it wrapped into a connection.DB

type DB

type DB struct {
	// contains filtered or unexported fields
}

DB wraps pgx.Conn into a struct that implements connection.DB

func (*DB) BeginTransaction

func (d *DB) BeginTransaction(ctx context.Context) (connection.DB, error)

BeginTransaction returns a new DB that will use the transaction instead of the basic conn. if the transaction is already started the same will be returned.

func (*DB) BulkInsert

func (d *DB) BulkInsert(_ context.Context, _ string, _ []string, _ [][]interface{}) (execError error)

BulkInsert only works with pgx driver.

func (*DB) Clone

func (d *DB) Clone() connection.DB

Clone returns a copy of DB with the same underlying Connection

func (*DB) Close added in v2.1.8

func (d *DB) Close() error

Close closes the underlying connection, beware, this makes the DB useless.

func (*DB) CommitTransaction

func (d *DB) CommitTransaction(_ context.Context) error

CommitTransaction commits the transaction if any is in course, behavior comes straight from pgx.

func (*DB) EExec

func (d *DB) EExec(ctx context.Context, statement string, args ...interface{}) error

EExec calls EscapeArgs before invoking Exec

func (*DB) EQuery

func (d *DB) EQuery(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetch, error)

EQuery calls EscapeArgs before invoking Query

func (*DB) EQueryIter

func (d *DB) EQueryIter(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetchIter, error)

EQueryIter Calls EscapeArgs before invoking QueryIter

func (*DB) EQueryPrimitive

func (d *DB) EQueryPrimitive(ctx context.Context, statement string, field string, args ...interface{}) (connection.ResultFetch, error)

EQueryPrimitive calls EscapeArgs before invoking QueryPrimitive.

func (*DB) ERaw

func (d *DB) ERaw(ctx context.Context, statement string, args []interface{}, fields ...interface{}) error

ERaw calls EscapeArgs before invoking Raw

func (*DB) Exec

func (d *DB) Exec(ctx context.Context, statement string, args ...interface{}) error

Exec will run the statement and expect nothing in return.

func (*DB) ExecResult

func (d *DB) ExecResult(ctx context.Context, statement string, args ...interface{}) (int64, error)

ExecResult will run the statement and return the number of rows affected.

func (*DB) IsTransaction

func (d *DB) IsTransaction() bool

IsTransaction indicates if the DB is in the middle of a transaction.

func (*DB) Query

func (d *DB) Query(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetch, error)

Query returns a function that allows recovering the results of the query, beware the connection is held until the returned closure is invoked.

func (*DB) QueryIter

func (d *DB) QueryIter(ctx context.Context, statement string, fields []string, args ...interface{}) (connection.ResultFetchIter, error)

QueryIter returns an iterator that can be used to fetch results one by one, beware this holds the connection until fetching is done. the passed fields are supposed to correspond to the fields being brought from the db, no check is performed on this.

func (*DB) QueryPrimitive

func (d *DB) QueryPrimitive(ctx context.Context, statement string, _ string, args ...interface{}) (connection.ResultFetch, error)

QueryPrimitive returns a function that allows recovering the results of the query but to a slice of a primitive type, only allowed if the query fetches one field.

func (*DB) Raw

func (d *DB) Raw(ctx context.Context, statement string, args []interface{}, fields ...interface{}) error

Raw will run the passed statement with the passed args and scan the first result, if any, to the passed fields.

func (*DB) RollbackTransaction

func (d *DB) RollbackTransaction(_ context.Context) error

RollbackTransaction rolls back the transaction if any is in course, behavior comes straight from pgx.

func (*DB) Set

func (d *DB) Set(ctx context.Context, set string) error

Set tries to run `SET LOCAL` with the passed parameters if there is an ongoing transaction. https://www.postgresql.org/docs/9.2/static/sql-set.html

Jump to

Keyboard shortcuts

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