pq 是一个纯 Go 语言实现的 PostgreSQL 数据库客户端驱动包。
特性:
SSL
Handles bad connections for database/sql
database/sql
Scan time.Time correctly (i.e. timestamp[tz], time[tz], date)
time.Time
timestamp[tz]
time[tz]
date
Scan binary blobs correctly (i.e. bytea)
bytea
Package for hstore support
hstore
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
LISTEN
NOTIFY
示例代码:
package main import ( _ "github.com/bmizerany/pq" "database/sql" ) func main() { db, err := sql.Open("postgres", "user=pqgotest dbname=pqgotest sslmode=verify-full") // ... }