postgrespq

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2019 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultPGPoolMaxConn = 10

DefaultPGPoolMaxConn is an arbitrary number of connections that I decided was ok for the pool

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() (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(tableName string, columns []string, values [][]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) CommitTransaction

func (d *DB) CommitTransaction() error

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

func (*DB) EExec added in v0.1.16

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

EExec calls EscapeArgs before invoking Exec

func (*DB) EQuery added in v0.1.16

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

EQuery calls EscapeArgs before invoking Query

func (*DB) EQueryIter added in v0.1.16

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

EQueryIter Calls EscapeArgs before invoking QueryIter

func (*DB) EQueryPrimitive added in v0.1.16

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

EQueryPrimitive calls EscapeArgs before invoking QueryPrimitive.

func (*DB) ERaw added in v0.1.16

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

ERaw calls EscapeArgs before invoking Raw

func (*DB) Exec

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

Exec will run the statement and expect nothing in return.

func (*DB) ExecResult added in v0.1.17

func (d *DB) ExecResult(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(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 closusure is invoked.

func (*DB) QueryIter

func (d *DB) QueryIter(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(statement string, field string, args ...interface{}) (connection.ResultFetch, error)

QueryPrimitive returns a function that allowss 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(statement string, args []interface{}, fields ...interface{}) error

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

func (*DB) RollbackTransaction

func (d *DB) RollbackTransaction() error

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

func (*DB) Set

func (d *DB) Set(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