This is a pre-production deployment of Warehouse, however changes made here WILL affect the production instance of PyPI.
Latest Version Dependencies status unknown Test status unknown Test coverage unknown
Project Description
  • Lightweight
  • Written entirely in Python
  • No external dependencies
  • Not thread-safe


$ pip install pgsql


import pgsql

# address defaults to ("localhost", 5432), a string must point to a unix socket
# user defaults to "postgres"
# password defaults to None
# database equals user by default
db = pgsql.Connection(user = "antti", database = "postgres")
print(db("CREATE TABLE people (name TEXT, age INT)"))
print(db("INSERT INTO people (name, age) VALUES ($1, $2)", "Veronica", 18))
print(db("SELECT * FROM people"))

# for convenience, connection objects support the with statement
with pgsql.Connection(user = "antti", database = "postgres") as db:
        # you can use .begin(), .commit(), .rollback() manually, or use the with statement
        with db.transaction():
                with db.prepare("INSERT INTO people (name, age) VALUES ($1, $2)") as ps:
                        for person in ("Wallace", 18), ("Keith", 45), ("Lianne", 44):

        # iterate through and print all the rows represented as tuples
        people = db.prepare("SELECT * FROM people")
        for person in people():

        # sometimes instead of an iterator, you want the rows as a list
        # you may also want to call columns by their name
        people_over = db.prepare("SELECT * FROM people WHERE age > $1").all
        for person in people_over(21):
                print(, "is", person.age - 21, "years over the age of 21")

        # when the expected result is only one row, it's convenient to call .first
        person_named = db.prepare("SELECT * FROM people WHERE name = $1 LIMIT 1").first


[('Veronica', 18)]
('Veronica', 18)
('Wallace', 18)
('Keith', 45)
('Lianne', 44)
Keith is 24 years over the age of 21
Lianne is 23 years over the age of 21
('Veronica', 18)


1.1 (2014-03-26)

  • Make it possible to execute one-time statements by calling the Connection object
Release History

Release History


This version

History Node

TODO: Figure out how to actually get changelog content.

Changelog content for this version goes here.

Donec et mollis dolor. Praesent et diam eget libero egestas mattis sit amet vitae augue. Nam tincidunt congue enim, ut porta lorem lacinia consectetur. Donec ut libero sed arcu vehicula ultricies a non tortor. Lorem ipsum dolor sit amet, consectetur adipiscing elit.

Show More

Download Files

Download Files

TODO: Brief introduction on what you do with files - including link to relevant help section.

File Name & Checksum SHA256 Checksum Help Version File Type Upload Date
pgsql-1.1.tar.gz (4.8 kB) Copy SHA256 Checksum SHA256 Source Mar 26, 2014

Supported By

WebFaction WebFaction Technical Writing Elastic Elastic Search Pingdom Pingdom Monitoring Dyn Dyn DNS HPE HPE Development Sentry Sentry Error Logging CloudAMQP CloudAMQP RabbitMQ Heroku Heroku PaaS Kabu Creative Kabu Creative UX & Design Fastly Fastly CDN DigiCert DigiCert EV Certificate Rackspace Rackspace Cloud Servers DreamHost DreamHost Log Hosting