Categorygithub.com/cockroachdb/pq
modulepackage
0.0.0-20170214192453-5aaaa51a9fb5
Repository: https://github.com/cockroachdb/pq.git
Documentation: pkg.go.dev

# README

NOTICE

CockroachDB forked lib/pq to make some custom changes, but we have since migrated back to lib/pq and this package is no longer in use. It is kept here for historical reasons.


pq - A pure Go postgres driver for Go's database/sql package

Build Status

Install

go get github.com/lib/pq

Docs

For detailed documentation and basic usage examples, please see the package documentation at http://godoc.org/github.com/lib/pq.

Tests

go test is used for testing. A running PostgreSQL server is required, with the ability to log in. The default database to connect to test with is "pqgotest," but it can be overridden using environment variables.

Example:

PGHOST=/run/postgresql go test github.com/lib/pq

Optionally, a benchmark suite can be run as part of the tests:

PGHOST=/run/postgresql go test -bench .

Features

  • SSL
  • Handles bad connections for database/sql
  • Scan time.Time correctly (i.e. timestamp[tz], time[tz], date)
  • Scan binary blobs correctly (i.e. bytea)
  • Package for hstore support
  • COPY FROM support
  • pq.ParseURL for converting urls to connection strings for sql.Open.
  • Many libpq compatible environment variables
  • Unix socket support
  • Notifications: LISTEN/NOTIFY
  • pgpass support

Future / Things you can help with

  • Better COPY FROM / COPY TO (see discussion in #181)

Thank you (alphabetical)

Some of these contributors are from the original library bmizerany/pq.go whose code still exists in here.

  • Andy Balholm (andybalholm)
  • Ben Berkert (benburkert)
  • Benjamin Heatwole (bheatwole)
  • Bill Mill (llimllib)
  • Bjørn Madsen (aeons)
  • Blake Gentry (bgentry)
  • Brad Fitzpatrick (bradfitz)
  • Charlie Melbye (cmelbye)
  • Chris Bandy (cbandy)
  • Chris Gilling (cgilling)
  • Chris Walsh (cwds)
  • Dan Sosedoff (sosedoff)
  • Daniel Farina (fdr)
  • Eric Chlebek (echlebek)
  • Eric Garrido (minusnine)
  • Eric Urban (hydrogen18)
  • Everyone at The Go Team
  • Evan Shaw (edsrzf)
  • Ewan Chou (coocood)
  • Fazal Majid (fazalmajid)
  • Federico Romero (federomero)
  • Fumin (fumin)
  • Gary Burd (garyburd)
  • Heroku (heroku)
  • James Pozdena (jpoz)
  • Jason McVetta (jmcvetta)
  • Jeremy Jay (pbnjay)
  • Joakim Sernbrant (serbaut)
  • John Gallagher (jgallagher)
  • Jonathan Rudenberg (titanous)
  • Joël Stemmer (jstemmer)
  • Kamil Kisiel (kisielk)
  • Kelly Dunn (kellydunn)
  • Keith Rarick (kr)
  • Kir Shatrov (kirs)
  • Lann Martin (lann)
  • Maciek Sakrejda (deafbybeheading)
  • Marc Brinkmann (mbr)
  • Marko Tiikkaja (johto)
  • Matt Newberry (MattNewberry)
  • Matt Robenolt (mattrobenolt)
  • Martin Olsen (martinolsen)
  • Mike Lewis (mikelikespie)
  • Nicolas Patry (Narsil)
  • Oliver Tonnhofer (olt)
  • Patrick Hayes (phayes)
  • Paul Hammond (paulhammond)
  • Ryan Smith (ryandotsmith)
  • Samuel Stauffer (samuel)
  • Timothée Peignier (cyberdelia)
  • Travis Cline (tmc)
  • TruongSinh Tran-Nguyen (truongsinh)
  • Yaismel Miranda (ympons)
  • notedit (notedit)

# Packages

No description provided by the author
Below you will find a self-contained Go program which uses the LISTEN / NOTIFY mechanism to avoid polling the database while waiting for more work to arrive.
Package oid contains OID constants as defined by the Postgres server.

# Functions

CopyIn creates a COPY FROM statement which can be prepared with Tx.Prepare().
CopyInSchema creates a COPY FROM statement which can be prepared with Tx.Prepare().
No description provided by the author
EnableInfinityTs controls the handling of Postgres' "-infinity" and "infinity" "timestamp"s.
FormatTimestamp formats t into Postgres' text format for timestamps.
NewDialListener is like NewListener but it takes a Dialer.
NewListener creates a new database connection dedicated to LISTEN / NOTIFY.
Creates a new ListenerConn.
No description provided by the author
ParseTimestamp parses Postgres' text format.
ParseURL no longer needs to be used by clients of this library since supplying a URL as a connection string to sql.Open() is now supported: sql.Open("postgres", "postgres://bob:[email protected]:5432/mydb?sslmode=verify-full") It remains exported here for backwards-compatibility.
QuoteIdentifier quotes an "identifier" (e.g.

# Constants

Error severities.
Error severities.
Error severities.
Error severities.
Error severities.
Error severities.
Error severities.
Emitted only when the database connection has been initially initialized.
Emitted after a connection to the database was attempted, but failed.
Emitted after a database connection has been lost, either because of an error or because Close has been called.
Emitted after a database connection has been re-established after connection loss.

# Variables

No description provided by the author
No description provided by the author
Common error types.
Common error types.
Common error types.
Common error types.
Common error types.
Common error types.

# Structs

Error represents an error communicating with the server.
Listener provides an interface for listening to notifications from a PostgreSQL database.
ListenerConn is a low-level interface for waiting for notifications.
Notification represents a single notification from the database.
NullTime represents a time.Time that may be null.

# Interfaces

No description provided by the author
PGError is an interface used by previous versions of pq.

# Type aliases

ErrorClass is only the class part of an error code.
ErrorCode is a five-character error code.
No description provided by the author
No description provided by the author