top
(README.md)
# 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](https://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](http://www.postgresql.org/docs/9.1/static/libpq-envars.html)
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)

Imported by 297 package(s)

  1. bitbucket.org/jaybill/sawsij/framework
  2. bitbucket.org/ongisnotaguild/obi-wan-kanbanobi/kanban
  3. github.com/3d0c/hood
  4. github.com/3fps/shawty/data
  5. github.com/3zcurdia/gotiny
  6. github.com/AndreMouche/beedb/example
  7. github.com/ArtemTeleshev/beedb/example
  8. github.com/BrandonY/gobyexample/examples/postgres
  9. github.com/Claymore/search-kladr
  10. github.com/CreaturePhil/gobyexample/examples/postgres
  11. github.com/DeyV/go-pgtest/hellosql
  12. github.com/FernandoEscher/golang-geo
  13. github.com/FreeFlightSim/golang-geo
  14. github.com/IMQS/sente
  15. github.com/JessonChan/beedb/example
  16. github.com/Khady/obiwan-kanbanobi/kanban
  17. github.com/MajorMJR/homesite
  18. github.com/MajorMJR/pingo
  19. github.com/MajorMJR/pingo/server
  20. github.com/Miniand/miniand-network/app/controllers
  21. github.com/MobiSolutions/beedb/example
  22. github.com/Murugan78/beedb/example
  23. github.com/MustWin/monitoring/app/models
  24. github.com/Mustwin/monitoring/app/models
  25. github.com/Neeke/beedb/example
  26. github.com/NoahShen/beedb/example
  27. github.com/Noxer/GoPostgreSQL
  28. github.com/OllyGinger/ImgurGallery
  29. github.com/RaymondChou/beedb/example
  30. github.com/Sas0ri/beedb/example
  31. github.com/SohoStudio/beedb/example
  32. github.com/SophisticaSean/meme_coin
  33. github.com/SophisticaSean/meme_coin/handlers
  34. github.com/StefanKjartansson/hood
  35. github.com/SunLnx/goblog/model
  36. github.com/TheOnly92/morioka/infrastructure
  37. github.com/YouthBuild-USA/godata
  38. github.com/ZachBergh/beedb/example
  39. github.com/aaronlifton/Gooo/model
  40. github.com/aaronlifton/gooo/model
  41. github.com/aidenliu/webanalytics
  42. github.com/anastasop/oneshot
  43. github.com/aquilax/novigeroi-go
  44. github.com/areski/beedb/example
  45. github.com/areski/cgrates/engine
  46. github.com/astaxie/beedb/example
  47. github.com/ateleshev/beedb/example
  48. github.com/avidal/chihaya/storage/batter
  49. github.com/aybabtme/goblog/model
  50. github.com/bbezuk/upnode
  51. github.com/bboyxu/gobyexample/examples/postgres
  52. github.com/bgentry/gls
  53. github.com/bgentry/hk/hkdist
  54. github.com/bgentry/l2met/librato_outlet
  55. github.com/bgentry/l2met/token
  56. github.com/bittersweet/gobyexample/examples/postgres
  57. github.com/blachniet/gobyexample/examples/postgres
  58. github.com/boostbob/beedb/example
  59. github.com/bortzmeyer/GoRTR
  60. github.com/bortzmeyer/GoRTR/database-store-client
  61. github.com/brandur/blackswan-go
  62. github.com/brandur/umbrella
  63. github.com/brettbuddin/gorp
  64. github.com/c0gent/auctionLog
  65. github.com/c0gent/halloween
  66. github.com/c0gent/halloween/bak
  67. github.com/cartwright/kitchenSink/sinkDb
  68. github.com/clooth/cares
  69. github.com/collinvandyck/go-and-java/go
  70. github.com/coocood/hood
  71. github.com/coreywang/hood
  72. github.com/coyotey/gobyexample/examples/postgres
  73. github.com/custa/gobyexample/examples/postgres
  74. github.com/cwc/asset-tracker
  75. github.com/cwc/asset-tracker/models
  76. github.com/dandavison/gobyexample/examples/postgres
  77. github.com/daneharrigan/hk/hkdist
  78. github.com/davidglivar/bookmarked
  79. github.com/davidglivar/datum/src/db
  80. github.com/davidglivar/datum/src/model
  81. github.com/davsk/eve/analysis
  82. github.com/dcosson/beedb/example
  83. github.com/deepfryed/go-vs-swift
  84. github.com/devonestes/gobyexample/examples/postgres
  85. github.com/divan/gobyexample/examples/postgres
  86. github.com/divoxx/hood
  87. github.com/dlintw/gobyexample/examples/postgres
  88. github.com/dongaihua/beedb/example
  89. github.com/doun/beedb/example
  90. github.com/doun/hood
  91. github.com/dpiddy/go-pq-test
  92. github.com/dpiddy/hk/hkdist
  93. github.com/dpritchett/hk/hkdist
  94. github.com/drbawb/chihaya/storage/batter
  95. github.com/earlbalai/shorty
  96. github.com/earlbalai/thebus
  97. github.com/easonchou/beedb/example
  98. github.com/elvin-du/beedb/example
  99. github.com/erikh/g211-web-go
  100. github.com/erikh/g211-web-go/get-loud
  101. github.com/erikh/g211-web-go/import
  102. github.com/everyx/gobyexample/examples/postgres
  103. github.com/fabiokung/gls
  104. github.com/fanatic/hk/hkdist
  105. github.com/fanliao/beedb/example
  106. github.com/fdr/hk/hkdist
  107. github.com/fenimore/disktag
  108. github.com/fenimore/mappyr-backend/database
  109. github.com/financeCoding/gobyexample/examples/postgres
  110. github.com/firebitsbr/gobyexample/examples/postgres
  111. github.com/flynn-archive/flynn-cli-dist
  112. github.com/freeflightsim/golang-geo
  113. github.com/funnylookinhat/gobyexample/examples/postgres
  114. github.com/gabstv/beedb/example
  115. github.com/gamache/hood
  116. github.com/georgyo/beedb/example
  117. github.com/glycerine/beedb/example
  118. github.com/gokyle/golobsters/dbase
  119. github.com/gokyle/rsstotwitter/dbase
  120. github.com/golibs/um/pg
  121. github.com/gqf2008/beedb/example
  122. github.com/hardPass/beedb/example
  123. github.com/hefju/GoFirst
  124. github.com/heidsoft/beedb/example
  125. github.com/helmi03/golang-stuff/github.com/astaxie/beedb/example
  126. github.com/helmi03/golang-stuff/github.com/mmcgrana/gobyexample/examples/postgres
  127. github.com/hgmnz/observatory
  128. github.com/hobbs/beedb/example
  129. github.com/huyan/beedb/example
  130. github.com/hydrogen2005/analytics.go
  131. github.com/hypermusk/todoapp/server
  132. github.com/icasimpan/gobyexample/examples/postgres
  133. github.com/imdario/gotli
  134. github.com/inconshreveable/hk/hkdist
  135. github.com/ismasan/datagram.io/db
  136. github.com/jameswei/beedb/example
  137. github.com/janne/gometrics
  138. github.com/jasonrdsouza/foosball_monkey/datastore
  139. github.com/jaybill/sawsij/framework
  140. github.com/jaywgraves/gobyexample/examples/postgres
  141. github.com/jeffadams78/address-autocomplete
  142. github.com/jingweno/hk/hkdist
  143. github.com/jlhonora/honorato.org/playground
  144. github.com/jlouis/rank
  145. github.com/jonesdeini/sandvich_webcrawler
  146. github.com/jonsen/beedb/example
  147. github.com/jonsen/gobyexample/examples/postgres
  148. github.com/jspaulding/hood
  149. github.com/justinbarry/hood
  150. github.com/kashdan/gobyexample/examples/postgres
  151. github.com/kbajey/gobyexample/examples/postgres
  152. github.com/kekek/gobyexample/examples/postgres
  153. github.com/kmagoye/go/goByExample/examples/postgres
  154. github.com/kr/hk/hkdist
  155. github.com/kristofer/Gooo/model
  156. github.com/kulasama/beedb/example
  157. github.com/layeka/beedb/example
  158. github.com/lbolla/hood
  159. github.com/leverly/gobyexample/examples/postgres
  160. github.com/linphy/beedb/example
  161. github.com/linuxmaniac/pkg-cgrates/engine
  162. github.com/liudch/beedb/example
  163. github.com/liusongsen/beedb/example
  164. github.com/liuzhe0223/beedb/example
  165. github.com/lukegb/hood
  166. github.com/magastzheng/beedb/example
  167. github.com/makhov/gobyexample/examples/postgres
  168. github.com/maratart/gobyexample/examples/postgres
  169. github.com/markpasc/cares
  170. github.com/martinhansdk/beedb/example
  171. github.com/maxpolun/go-weightlog/util
  172. github.com/mblair/go-by-example/src
  173. github.com/michaelboke/beedb/example
  174. github.com/mikejihbe/beedb/example
  175. github.com/milliyang/golang-stuff/github.com/astaxie/beedb/example
  176. github.com/milliyang/golang-stuff/github.com/mmcgrana/gobyexample/examples/postgres
  177. github.com/millken/cgrates/engine
  178. github.com/mkopta/nephos/src
  179. github.com/mmcfarland/address-autocomplete
  180. github.com/mmcfarland/go-tiler
  181. github.com/mmcfarland/plk
  182. github.com/mmcfarland/prc
  183. github.com/mmcgrana/gobyexample/examples/postgres
  184. github.com/mroote/homesite
  185. github.com/mroote/pingo
  186. github.com/mroote/pingo/server
  187. github.com/msgbox/storage
  188. github.com/msp8955/bismark-passive-server-go/passive
  189. github.com/mtabini/golang-geo
  190. github.com/muroachanf/beedb/example
  191. github.com/murz/ego/db
  192. github.com/naaman/hk/hkdist
  193. github.com/nagae-memooff/beedb/example
  194. github.com/nanjishidu/beedb/example
  195. github.com/natemontgomery/rvrn
  196. github.com/nateriver520/beedb/example
  197. github.com/natmeox/mess
  198. github.com/natmeox/mess/cmd
  199. github.com/nemowen/golang/postgresql
  200. github.com/nexneo/beedb/example
  201. github.com/nikai3d/gobyexample/examples/postgres
  202. github.com/nilslice/um/pg
  203. github.com/nobu-k/beedb/example
  204. github.com/nordicdyno/shawty/data
  205. github.com/notedit/eightfoot/backend/src/server
  206. github.com/nowk/bouncer
  207. github.com/noxer/GoPostgreSQL
  208. github.com/nsan1129/auctionLog
  209. github.com/ohlinux/golang-snippet-cn/gobyexample/examples/postgres
  210. github.com/oldtree/beedb/example
  211. github.com/pankajghosh/flickfind-discard
  212. github.com/patamushta/gobyexample/examples/postgres
  213. github.com/patrick-higgins/go-and-java/go
  214. github.com/patrickToca/bootic_data_collector/db
  215. github.com/pearkes/hood
  216. github.com/pearkes/up-server
  217. github.com/phacops/hood
  218. github.com/pilu/cerebellum
  219. github.com/pilu/microphone
  220. github.com/polypmer/mappyr-backend/database
  221. github.com/prinsmike/hood
  222. github.com/pvh/femebe/tools
  223. github.com/qbit/woody
  224. github.com/qwertmax/interview_tasks
  225. github.com/qwertmax/quiz-go/db
  226. github.com/qwertmax/timeconverter/db
  227. github.com/rdscorreia/gobyexample/examples/postgres
  228. github.com/redneckbeard/hood
  229. github.com/remigijusj/beedb/example
  230. github.com/rhencke/mess
  231. github.com/rhencke/mess/cmd
  232. github.com/rif/gocmd/postgres
  233. github.com/robertojrojas/gobyexample/examples/postgres
  234. github.com/robfig/modsql/test
  235. github.com/robyoung/beedb/example
  236. github.com/roessland/gobyexample/examples/postgres
  237. github.com/romanoff/beedb/example
  238. github.com/ryandotsmith/boc
  239. github.com/ryandotsmith/komrade/store
  240. github.com/ryandotsmith/m2pg
  241. github.com/ryandotsmith/wcld
  242. github.com/sburnett/bismark-passive-server-go/passive
  243. github.com/sburnett/bismark-tools/availability-intervals
  244. github.com/sburnett/bismark-tools/bdmq/commands
  245. github.com/sburnett/bismark-tools/bdmq/datastore
  246. github.com/scottcagno/Gooo/model
  247. github.com/scottcagno/beedb/example
  248. github.com/sdming/kdb/example
  249. github.com/shadowmint/go-fluent
  250. github.com/sjltaylor/datagram.io/db
  251. github.com/sjp38/AndnyangWeb
  252. github.com/sluu99/shawty/data
  253. github.com/sluu99/um/pg
  254. github.com/snluu/shawty/data
  255. github.com/snluu/um/pg
  256. github.com/snyderep/genreco/go/src/github.com/snyderep/recogen/database
  257. github.com/softlns/beedb/example
  258. github.com/songofhack/beedb/example
  259. github.com/soulinfo/kdb/example
  260. github.com/spiffytech/bible_fixer
  261. github.com/spyrexd/bank_failure/process_bank_info
  262. github.com/stehem/plenty_of_links
  263. github.com/stormdock/gobyexample/examples/postgres
  264. github.com/svalleru/gobyexample/examples/postgres
  265. github.com/szabba/gobyexample/examples/postgres
  266. github.com/tenmozes/gobyexample/examples/postgres
  267. github.com/the-obsidian/mc/mcdist
  268. github.com/thetwentyone/beedb/example
  269. github.com/timdufrane/hood
  270. github.com/tonyjt/beedb/example
  271. github.com/trygo/beedb/example
  272. github.com/ttllpp/beedb/example
  273. github.com/uhoh-itsmaciek/gobyexample/examples/postgres
  274. github.com/ulugbekrozimboyev/gobyexample/examples/postgres
  275. github.com/uriel/hk/hkdist
  276. github.com/viniciusfeitosa/gobyexample/examples/postgres
  277. github.com/w4g3n3r/gopg
  278. github.com/wikiocracy/voteflow
  279. github.com/will/gobyexample/examples/postgres
  280. github.com/wujiang/goe/bqe
  281. github.com/wurkhappy/WH-Agreements/DB
  282. github.com/wurkhappy/WH-Agreements/models
  283. github.com/wurkhappy/WH-Comments/DB
  284. github.com/wurkhappy/WH-PaymentInfo/DB
  285. github.com/wurkhappy/WH-Payments/DB
  286. github.com/wurkhappy/WH-Payments/models
  287. github.com/wurkhappy/WH-Tasks/DB
  288. github.com/wurkhappy/WH-Tasks/models
  289. github.com/wurkhappy/WH-Transactions/DB
  290. github.com/wurkhappy/WH-UserService/DB
  291. github.com/xiocode/jet/example
  292. github.com/xuxiao/beedb/example
  293. github.com/yml/botbot-bot
  294. github.com/z8/mind
  295. github.com/z8/mind/utility
  296. github.com/zhaming/beedb/example
  297. simplex.sh/store

Imported only in test by 27 package(s)

  1. bitbucket.org/jaybill/sawsij/framework/model
  2. github.com/DDRBoxman/crud
  3. github.com/DeyV/gorp
  4. github.com/NoahShen/gorp
  5. github.com/SohoStudio/beego/orm
  6. github.com/ZhuBicen/beego/orm
  7. github.com/adamflott/gorp
  8. github.com/cgyy/jet
  9. github.com/ddrboxman/crud
  10. github.com/doun/gorp
  11. github.com/dworld/gorp
  12. github.com/fvbock/gorp
  13. github.com/hpgood/gorp
  14. github.com/ideamean/beego/orm
  15. github.com/jaybill/sawsij/framework/model
  16. github.com/lemmi/gorp
  17. github.com/modcloth/gorp
  18. github.com/nexneo/gorp
  19. github.com/notedit/eightfoot/backend/src/service/content
  20. github.com/notedit/eightfoot/backend/src/service/tag
  21. github.com/notedit/eightfoot/backend/src/service/user
  22. github.com/shin-/gorp
  23. github.com/shykes/gorp
  24. github.com/sjltaylor/respond/auth
  25. github.com/tjyang/beego/orm
  26. github.com/xiocode/jet
  27. github.com/xumingming/beego/orm