• Stars
    star
    181
  • Rank 212,110 (Top 5 %)
  • Language
    Go
  • License
    MIT License
  • Created almost 12 years ago
  • Updated over 10 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

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

This package is now deprecated. The up to date version is at github.com/lib/pq.

Install

go get github.com/bmizerany/pq

Docs

http://go.pkgdoc.org/github.com/bmizerany/pq

Use

package main

import (
	_ "github.com/bmizerany/pq"
	"database/sql"
)

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.

See http://www.postgresql.org/docs/9.1/static/libpq-connect.html.

  • 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 http://golang.org/pkg/database/sql to learn how to use with pq through the database/sql package.

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=/var/run/postgresql go test pq

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)
  • 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)

More Repositories

1

pat

Go
1,413
star
2

roundup

eliminate bugs and weeds from shell scripts
Shell
427
star
3

noeqd

A fault-tolerant network service for meaningful GUID generation
Go
340
star
4

sinatra-activerecord

Extends Sinatra with ActiveRecord helper methods and Rake tasks (now maintained by @holman).
Ruby
194
star
5

perks

Effective Computation of Things
Go
186
star
6

assert

Asserts to Go testing
Go
142
star
7

sinatra-dj

a simple piglatin app to show off sinatra + DJ
Ruby
81
star
8

aws4

A Go package for AWS Signature version 4
Go
73
star
9

sinatra-redis

A light extension for using redis with Sinatra
Ruby
60
star
10

lizzy

An DSL for creating AMQP agents; quickly.
Ruby
53
star
11

vendor

Vendor copies go dependencies to ./vendor
Go
52
star
12

onis

runtime object introspection for ruby process
Ruby
44
star
13

pq.go

Go
39
star
14

sinatra-captcha

Quick, simple, fast captcha for Sinatra
Ruby
37
star
15

mc

Binary Memcached client for Go with SASL support
Go
34
star
16

heroku-sinatra-app

Ruby
32
star
17

aws

An old simple AWS client in Go (use bmizerany/aws4 for more up to date aws usage).
Go
26
star
18

sinatra-any

Granular before filters for sinatra
Ruby
24
star
19

redis-erl

Minimilast Redis Client for Erlang
Erlang
21
star
20

swirl

API version agnostic EC2 client
Ruby
20
star
21

beldam

clean, easy, ec2 wrapper
Ruby
14
star
22

logplex

Go
14
star
23

swirl-node

JavaScript
13
star
24

em-swirl

An evented Ruby EC2 driver for EventMachine
Ruby
12
star
25

recho

echo(1) in ruby
Ruby
11
star
26

nodefinder

Erlang node finders
11
star
27

pqx

Go
10
star
28

noeq.go

Go client for noeqd
Go
10
star
29

sinatra-slaushed

redis powered authentication for Sinatra
Ruby
9
star
30

frylock

Ruby + CLI + DSL = Command line apps made easy! (Not ready yet)
Ruby
8
star
31

supermemo

SM2 application
Ruby
7
star
32

inotify-ffi

Ruby
7
star
33

guns

It has two pipes; got tickets to the show?
Ruby
7
star
34

noeq

A command line client for noeqd
Go
6
star
35

lpx

Logplex framing parser
Go
6
star
36

lively-docs

Escape the hell of `rake rdoc` .. edit .. `rake rdoc` .. edit .. etc.
5
star
37

pat.go

Now at bmizerany/pat
Go
5
star
38

WAck

Ack! for the web.
Ruby
5
star
39

heroku-docs

Documentation for Heroku, in the form of a Sinatra app serving markdown text files.
Ruby
5
star
40

jabberlang

Erlang jabber client
5
star
41

sinatra-template-vendor

Ruby
4
star
42

domainy

for getting the base of a domain
Ruby
4
star
43

RedisPl

Redis Perl Bindings (from svn://svn.rot13.org/Redis/)
Perl
3
star
44

lameetup

Ruby
3
star
45

sinatra-sassacache

Extends Sinatra with a route to compile and cache Sass templates
3
star
46

test

a test for work
3
star
47

attrubates

Arrtubates sets meta on meta for objects and adds additional rendering helpers for ActionController::Base in Rails.
Ruby
3
star
48

lorem-me

Hacker's Lorem Ipsum Genereator with Gists.
Ruby
3
star
49

sinatra-ext-pres

Sinatra Extensions Presentation
Ruby
2
star
50

schemafinder

2
star
51

fido

he fetches
Shell
2
star
52

hk

Fast Heroku client
Go
2
star
53

Elephant

An Adium Plugin for keeping realtime backup/full-text search of all chats
Objective-C
2
star
54

pages

Go
2
star
55

aws.go

Go
2
star
56

muni

Quick muni notifications for us SF dwellers
1
star
57

doozer-bench

bechmark the doozerz
Go
1
star
58

bang

banger
Ruby
1
star
59

mc.go

Go
1
star
60

onis-web

1
star
61

vips

Go
1
star
62

fsh

Fuck syntax highlighting. The correct default for the Atom (atom.io) editor.
CSS
1
star
63

theherms

example - don't look
1
star