Documentation ¶
Index ¶
- type Connection
- type DB
- func (DB *DB) Close()
- func (DB *DB) Exec(query string, args ...interface{}) (pgconn.CommandTag, error)
- func (DB *DB) Get(target interface{}, query string, args ...interface{}) error
- func (DB *DB) NamedExec(query string, arg interface{}) (pgconn.CommandTag, error)
- func (DB *DB) NamedGet(target interface{}, query string, arg interface{}) error
- func (DB *DB) NamedQuery(query string, arg interface{}) (pgx.Rows, error)
- func (DB *DB) NamedQueryRow(query string, arg interface{}) (pgx.Row, error)
- func (DB *DB) NamedSelect(target interface{}, query string, arg interface{}) error
- func (DB *DB) Query(query string, args ...interface{}) (pgx.Rows, error)
- func (DB *DB) QueryRow(query string, args ...interface{}) pgx.Row
- func (DB *DB) Select(target interface{}, query string, args ...interface{}) error
- type PreparedNamedQuery
- func (p *PreparedNamedQuery) Exec(db *DB, arg interface{}) (pgconn.CommandTag, error)
- func (p *PreparedNamedQuery) Get(db *DB, target interface{}, arg interface{}) error
- func (p *PreparedNamedQuery) Query(db *DB, arg interface{}) (pgx.Rows, error)
- func (p *PreparedNamedQuery) QueryRow(db *DB, arg interface{}) (pgx.Row, error)
- func (p *PreparedNamedQuery) Select(db *DB, target interface{}, arg interface{}) error
- type PreparedQuery
- func (p *PreparedQuery) Exec(db *DB, args ...interface{}) (pgconn.CommandTag, error)
- func (p *PreparedQuery) Get(db *DB, target interface{}, args ...interface{}) error
- func (p *PreparedQuery) Query(db *DB, args ...interface{}) (pgx.Rows, error)
- func (p *PreparedQuery) QueryRow(db *DB, args ...interface{}) (pgx.Row, error)
- func (p *PreparedQuery) Select(db *DB, target interface{}, args ...interface{}) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Connection ¶
type Connection struct { User string // pgx defaults this to your OS username Password string Database string // the name of the database Host string // defaults to localhost Port string // defaults to 5432 SslMode string // defaults to disable PoolMaxConns int // default 4 PoolMinConns int // default 0 PoolMaxConnLifetime int // default time.Hour PoolMaxConnIdleTime int // default time.Minute * 30 PoolHealthCheckPeriod int // default time.Minute Logger pgx.Logger }
type DB ¶
DB stores the internal PgxPool
func Connect ¶
func Connect(conn Connection) (*DB, error)
Connect connects to the database NOTE: It does not support all the features that are on connection string yet Use is currently recommended to be used instead
func Use ¶
Use uses an already existing connection It assumes that the fed connection pool is not null
func (*DB) Exec ¶
func (DB *DB) Exec(query string, args ...interface{}) (pgconn.CommandTag, error)
Exec is used to run actions on database that wont return any values to the client
func (*DB) Get ¶
Get is a high-level function that is used to retrieve data from database into a single struct
func (*DB) NamedExec ¶
func (DB *DB) NamedExec(query string, arg interface{}) (pgconn.CommandTag, error)
NamedExec simplifies the parameters and allows the use of named parameters
func (*DB) NamedGet ¶
NamedGet is a high-level function that is used to retrieve data from database into structs
func (*DB) NamedQuery ¶
NamedQuery simplifies the parameters and allows the use of named parameters
func (*DB) NamedQueryRow ¶
NamedQueryRow simplifies the parameters and allows the use of named parameters
func (*DB) NamedSelect ¶
NamedSelect is a high-level function that is used to retrieve data from database into structs
type PreparedNamedQuery ¶ added in v0.2.0
type PreparedNamedQuery struct {
// contains filtered or unexported fields
}
func PrepareNamed ¶ added in v0.2.0
func PrepareNamed(sql string) (*PreparedNamedQuery, error)
Prepares a named SQL-query with :FieldName placeholders NOTE: This does not use the pgx way to prepare queries under the hood
func (*PreparedNamedQuery) Exec ¶ added in v0.2.0
func (p *PreparedNamedQuery) Exec(db *DB, arg interface{}) (pgconn.CommandTag, error)
func (*PreparedNamedQuery) Get ¶ added in v0.2.0
func (p *PreparedNamedQuery) Get(db *DB, target interface{}, arg interface{}) error
func (*PreparedNamedQuery) Query ¶ added in v0.2.0
func (p *PreparedNamedQuery) Query(db *DB, arg interface{}) (pgx.Rows, error)
func (*PreparedNamedQuery) QueryRow ¶ added in v0.2.0
func (p *PreparedNamedQuery) QueryRow(db *DB, arg interface{}) (pgx.Row, error)
func (*PreparedNamedQuery) Select ¶ added in v0.2.0
func (p *PreparedNamedQuery) Select(db *DB, target interface{}, arg interface{}) error
type PreparedQuery ¶ added in v0.2.0
type PreparedQuery struct {
// contains filtered or unexported fields
}
func Prepare ¶ added in v0.2.0
func Prepare(sql string) *PreparedQuery
Prepares a traditional SQL-query with $1, $2, $3 placeholders NOTE: This does not use the pgx way to prepare queries under the hood
func (*PreparedQuery) Exec ¶ added in v0.2.0
func (p *PreparedQuery) Exec(db *DB, args ...interface{}) (pgconn.CommandTag, error)
func (*PreparedQuery) Get ¶ added in v0.2.0
func (p *PreparedQuery) Get(db *DB, target interface{}, args ...interface{}) error
func (*PreparedQuery) Query ¶ added in v0.2.0
func (p *PreparedQuery) Query(db *DB, args ...interface{}) (pgx.Rows, error)
func (*PreparedQuery) QueryRow ¶ added in v0.2.0
func (p *PreparedQuery) QueryRow(db *DB, args ...interface{}) (pgx.Row, error)
func (*PreparedQuery) Select ¶ added in v0.2.0
func (p *PreparedQuery) Select(db *DB, target interface{}, args ...interface{}) error