License: MIT

Language: Go

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

This package is now deprecated. The up to date version is at


go get



package main

import (
    _ ""

func main() {
    db, err := sql.Open("postgres", "user=pqgotest dbname=pqgotest sslmode=verify-full")
    // ...

Connection String Parameters

These are a subset of the libpq connection parameters. In addition, a number of the environment variables supported by libpq are also supported. Just like libpq, these have lower precedence than explicitly provided connection parameters.


  • dbname - The name of the database to connect to
  • user - The user to sign in as
  • password - The user's password
  • host - The host to connect to. Values that start with / are for unix domain sockets. (default is localhost)
  • port - The port to bind to. (default is 5432)
  • sslmode - Whether or not to use SSL (default is require, this is not the default for libpq) Valid values are:
    • disable - No SSL
    • require - Always SSL (skip verification)
    • verify-full - Always SSL (require verification)

See to learn how to use with pq through the database/sql package.


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.


PGHOST=/var/run/postgresql go test pq


  • 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)
  • pq.ParseURL for converting urls to connection strings for sql.Open.
  • Many libpq compatible environment variables
  • Unix socket support

Future / Things you can help with

  • Notifications: LISTEN/NOTIFY
  • hstore sugar (i.e. handling hstore in rows.Scan)

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)
  • Bjørn Madsen (aeons)
  • Blake Gentry (bgentry)
  • Brad Fitzpatrick (bradfitz)
  • Daniel Farina (fdr)
  • Everyone at The Go Team
  • Federico Romero (federomero)
  • Heroku (heroku)
  • John Gallagher (jgallagher)
  • Kamil Kisiel (kisielk)
  • Keith Rarick (kr)
  • Marc Brinkmann (mbr)
  • Martin Olsen (martinolsen)
  • Mike Lewis (mikelikespie)
  • Ryan Smith (ryandotsmith)
  • Samuel Stauffer (samuel)
  • notedit (notedit)

Project Statistics

Sourcerank 7
Repository Size 232 KB
Stars 152
Forks 22
Watchers 11
Open issues 0
Dependencies 0
Contributors 11
Tags 0
Last updated
Last pushed

Top Contributors See all

Blake Mizerany John Gallagher Blake Gentry Andy Balholm Daniel Farina Ben Burkert Travis Cline Keith Rarick Marc Brinkmann Bjørn Madsen Martin Olsen

Packages Referencing this Repo
pq - A pure Go postgres driver for Go's database/sql package This package is now deprecated.
Latest release - Published - 152 stars

Interesting Forks See all

Go - MIT - Last pushed - 1 stars

Something wrong with this page? Make a suggestion

Last synced: 2016-11-24 15:08:04 UTC

Login to resync this repository