pq - PostgreSQL的Go语言驱动


MIT
Linux
Google Go

软件简介

pq 是一个纯 Go 语言实现的 PostgreSQL 数据库客户端驱动包。

特性:

  • 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

示例代码:

package main

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

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