postgresql

package
v4.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 3, 2022 License: MIT Imports: 18 Imported by: 74 modules, 70 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

PostgreSQL adapter for upper/db

Please read the full docs, acknowledgements and examples at https://upper.io/v4/adapter/postgresql/.

Documentation

Overview

Package postgresql provides an adapter for PostgreSQL. See https://github.com/upper/db/adapter/postgresql for documentation, particularities and usage examples.

Index

Constants

View Source
const Adapter = "postgresql"

Adapter is the internal name of the adapter.

Variables

This section is empty.

Functions

func JSONBValue

func JSONBValue(i interface{}) (driver.Value, error)

JSONBValue takes an interface and provides a driver.Value that can be stored as a JSONB column.

func New

func New(sqlDB *sql.DB) (db.Session, error)

New creates a sqlbuilder.Sesion instance by wrapping a *sql.DB value.

func NewTx

func NewTx(sqlTx *sql.Tx) (sqlbuilder.Tx, error)

NewTx creates a sqlbuilder.Tx instance by wrapping a *sql.Tx value.

func Open

func Open(connURL db.ConnectionURL) (db.Session, error)

Open establishes a connection to the database server and returns a sqlbuilder.Session instance (which is compatible with db.Session).

func ScanJSONB

func ScanJSONB(dst interface{}, src interface{}) error

ScanJSONB decodes a JSON byte stream into the passed dst value.

Types

type BoolArray

type BoolArray []bool

BoolArray represents a one-dimensional array of int64s (`[]bool{}`) that is compatible with PostgreSQL's boolean type (`boolean[]`). BoolArray satisfies sqlbuilder.ScannerValuer.

func (*BoolArray) Scan

func (ba *BoolArray) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (BoolArray) Value

func (ba BoolArray) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

type Bytea added in v4.5.0

type Bytea []byte

func (*Bytea) Scan added in v4.5.0

func (b *Bytea) Scan(src interface{}) error

func (Bytea) Value added in v4.5.0

func (b Bytea) Value() (driver.Value, error)

type ByteaArray added in v4.5.0

type ByteaArray [][]byte

ByteaArray represents a one-dimensional array of strings (`[]string{}`) that is compatible with PostgreSQL's text array (`text[]`). ByteaArray satisfies sqlbuilder.ScannerValuer.

func (*ByteaArray) Scan added in v4.5.0

func (ba *ByteaArray) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (ByteaArray) Value added in v4.5.0

func (a ByteaArray) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

type ConnectionURL

type ConnectionURL struct {
	User     string
	Password string
	Host     string
	Socket   string
	Database string
	Options  map[string]string
	// contains filtered or unexported fields
}

ConnectionURL represents a parsed PostgreSQL connection URL.

You can use a ConnectionURL struct as an argument for Open:

var settings = postgresql.ConnectionURL{
  Host:       "localhost",          // PostgreSQL server IP or name.
  Database:   "peanuts",            // Database name.
  User:       "cbrown",             // Optional user name.
  Password:   "snoopy",             // Optional user password.
}

sess, err = postgresql.Open(settings)

If you already have a valid DSN, you can use ParseURL to convert it into a ConnectionURL before passing it to Open.

func ParseURL

func ParseURL(s string) (u *ConnectionURL, err error)

ParseURL parses the given DSN into a ConnectionURL struct. A typical PostgreSQL connection URL looks like:

postgres://bob:secret@1.2.3.4:5432/mydb?sslmode=verify-full

func (ConnectionURL) String

func (c ConnectionURL) String() (s string)

String reassembles the parsed PostgreSQL connection URL into a valid DSN.

type Float32Array added in v4.5.0

type Float32Array []float32

Float32Array represents a one-dimensional array of float32s (`[]float32{}`) that is compatible with PostgreSQL's double precision array (`double precision[]`). Float32Array satisfies sqlbuilder.ScannerValuer.

func (*Float32Array) Scan added in v4.5.0

func (f32a *Float32Array) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (Float32Array) Value added in v4.5.0

func (f32a Float32Array) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

type Float64Array

type Float64Array []float64

Float64Array represents a one-dimensional array of float64s (`[]float64{}`) that is compatible with PostgreSQL's double precision array (`double precision[]`). Float64Array satisfies sqlbuilder.ScannerValuer.

func (*Float64Array) Scan

func (f64a *Float64Array) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (Float64Array) Value

func (f64a Float64Array) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

type Int32Array added in v4.5.0

type Int32Array []int32

Int32Array represents a one-dimensional array of int32s (`[]int32{}`) that is compatible with PostgreSQL's integer array (`integer[]`). Int32Array satisfies sqlbuilder.ScannerValuer.

func (*Int32Array) Scan added in v4.5.0

func (i32a *Int32Array) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (Int32Array) Value added in v4.5.0

func (i32a Int32Array) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

type Int64Array

type Int64Array []int64

Int64Array represents a one-dimensional array of int64s (`[]int64{}`) that is compatible with PostgreSQL's integer array (`integer[]`). Int64Array satisfies sqlbuilder.ScannerValuer.

func (*Int64Array) Scan

func (i64a *Int64Array) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (Int64Array) Value

func (i64a Int64Array) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

type JSONB

type JSONB struct {
	Data interface{}
}

JSONB represents a PostgreSQL's JSONB value: https://www.postgresql.org/docs/9.6/static/datatype-json.html. JSONB satisfies sqlbuilder.ScannerValuer.

func (JSONB) MarshalJSON

func (j JSONB) MarshalJSON() ([]byte, error)

MarshalJSON encodes the wrapper value as JSON.

func (*JSONB) Scan

func (j *JSONB) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (*JSONB) UnmarshalJSON

func (j *JSONB) UnmarshalJSON(b []byte) error

UnmarshalJSON decodes the given JSON into the wrapped value.

func (JSONB) Value

func (j JSONB) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

type JSONBArray

type JSONBArray []interface{}

JSONBArray represents an array of any type (`[]interface{}`) that is compatible with PostgreSQL's JSONB type. JSONBArray satisfies sqlbuilder.ScannerValuer.

func (*JSONBArray) Scan

func (a *JSONBArray) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (JSONBArray) Value

func (a JSONBArray) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

type JSONBConverter

type JSONBConverter struct {
}

func (*JSONBConverter) ConvertValue added in v4.5.0

func (*JSONBConverter) ConvertValue(in interface{}) interface {
	sql.Scanner
	driver.Valuer
}

type JSONBMap

type JSONBMap map[string]interface{}

JSONBMap represents a map of interfaces with string keys (`map[string]interface{}`) that is compatible with PostgreSQL's JSONB type. JSONBMap satisfies sqlbuilder.ScannerValuer.

func (*JSONBMap) Scan

func (m *JSONBMap) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (JSONBMap) Value

func (m JSONBMap) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

type StringArray

type StringArray []string

StringArray represents a one-dimensional array of strings (`[]string{}`) that is compatible with PostgreSQL's text array (`text[]`). StringArray satisfies sqlbuilder.ScannerValuer.

func (*StringArray) Scan

func (sa *StringArray) Scan(src interface{}) error

Scan satisfies the sql.Scanner interface.

func (StringArray) Value

func (a StringArray) Value() (driver.Value, error)

Value satisfies the driver.Valuer interface.

Jump to

Keyboard shortcuts

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