Documentation ¶
Index ¶
- Constants
- type Connector
- type DB
- func (d *DB) BeginTransaction() (connection.DB, error)
- func (d *DB) BulkInsert(tableName string, columns []string, values [][]interface{}) (execError error)
- func (d *DB) Clone() connection.DB
- func (d *DB) CommitTransaction() error
- func (d *DB) EExec(statement string, args ...interface{}) error
- func (d *DB) EQuery(statement string, fields []string, args ...interface{}) (connection.ResultFetch, error)
- func (d *DB) EQueryIter(statement string, fields []string, args ...interface{}) (connection.ResultFetchIter, error)
- func (d *DB) EQueryPrimitive(statement string, field string, args ...interface{}) (connection.ResultFetch, error)
- func (d *DB) ERaw(statement string, args []interface{}, fields ...interface{}) error
- func (d *DB) Exec(statement string, args ...interface{}) error
- func (d *DB) ExecResult(statement string, args ...interface{}) (int64, error)
- func (d *DB) IsTransaction() bool
- func (d *DB) Query(statement string, fields []string, args ...interface{}) (connection.ResultFetch, error)
- func (d *DB) QueryIter(statement string, fields []string, args ...interface{}) (connection.ResultFetchIter, error)
- func (d *DB) QueryPrimitive(statement string, field string, args ...interface{}) (connection.ResultFetch, error)
- func (d *DB) Raw(statement string, args []interface{}, fields ...interface{}) error
- func (d *DB) RollbackTransaction() error
- func (d *DB) Set(set string) error
Constants ¶
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 ¶
func (c *Connector) Open(ci *connection.Information) (connection.DB, error)
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 will use postgres copy function to try to insert a lot of data. You might need to use pgx types for the values to reduce probability of failure. https://godoc.org/github.com/jackc/pgx#Conn.CopyFrom
func (*DB) Clone ¶
func (d *DB) Clone() connection.DB
Clone returns a copy of DB with the same underlying Connection
func (*DB) CommitTransaction ¶
CommitTransaction commits the transaction if any is in course, beavior comes straight from pgx.
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) ExecResult ¶ added in v0.1.17
ExecResult will run the statement and return the number of rows affected.
func (*DB) IsTransaction ¶
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 ¶ added in v0.1.9
func (d *DB) QueryPrimitive(statement string, field 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 ¶
Raw will run the passed statement with the passed args and scan the first resul, if any, to the passed fields.
func (*DB) RollbackTransaction ¶
RollbackTransaction rolls back the transaction if any is in course, beavior comes straight from pgx.