# README
pq - A pure Go postgres driver for Go's database/sql package
Install
go get github.com/lib/pq
Docs
For detailed documentation and basic usage examples, please see the package documentation at https://godoc.org/github.com/lib/pq.
Tests
go test
is used for testing. See TESTS.md for more details.
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 (uhoh-itsmaciek)
- 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)
# Functions
Array returns the optimal driver.Valuer and sql.Scanner for an array or slice of any dimension.
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().
DialOpen opens a new connection to the database using a dialer.
EnableInfinityTs controls the handling of Postgres' "-infinity" and "infinity" "timestamp"s.
FormatTimestamp formats t into Postgres' text format for timestamps.
NewConnector returns a connector for the pq driver in a fixed configuration with the given dsn.
NewDialListener is like NewListener but it takes a Dialer.
NewListener creates a new database connection dedicated to LISTEN / NOTIFY.
NewListenerConn creates a new ListenerConn.
Open opens a new connection to the database.
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.
QuoteLiteral quotes a 'literal' (e.g.
# Constants
Error severities.
Error severities.
Error severities.
Error severities.
Error severities.
Error severities.
Error severities.
ListenerEventConnected is emitted only when the database connection has been initially initialized.
ListenerEventConnectionAttemptFailed is emitted after a connection to the database was attempted, but failed.
ListenerEventDisconnected is emitted after a database connection has been lost, either because of an error or because Close has been called.
ListenerEventReconnected is emitted after a database connection has been re-established after connection loss.
# Variables
ErrChannelAlreadyOpen is returned from Listen when a channel is already open.
ErrChannelNotOpen is returned from Unlisten when a channel is not open.
Common error types.
Common error types.
Common error types.
Common error types.
Common error types.
# Structs
Connector represents a fixed configuration for the pq driver with a given name.
Driver is the Postgres database driver.
Error represents an error communicating with the server.
GenericArray implements the driver.Valuer and sql.Scanner interfaces for an array or slice of any dimension.
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
ArrayDelimiter may be optionally implemented by driver.Valuer or sql.Scanner to override the array delimiter used by GenericArray.
Dialer is the dialer interface.
DialerContext is the context-aware dialer interface.
PGError is an interface used by previous versions of pq.
# Type aliases
BoolArray represents a one-dimensional array of the PostgreSQL boolean type.
ByteaArray represents a one-dimensional array of the PostgreSQL bytea type.
ErrorClass is only the class part of an error code.
ErrorCode is a five-character error code.
EventCallbackType is the event callback type.
Float64Array represents a one-dimensional array of the PostgreSQL double precision type.
Int64Array represents a one-dimensional array of the PostgreSQL integer types.
ListenerEventType is an enumeration of listener event types.
StringArray represents a one-dimensional array of the PostgreSQL character types.