Skip to main content

DB-API compatible interface on top of PL/Python

Project description

plpydbapi
=========

This module provides a (sort of) Python DB-API 2.0 compatible
interface on top of PL/Python.

About DB-API: <http://www.python.org/dev/peps/pep-0249/>

About PL/Python: <http://www.postgresql.org/docs/current/static/plpython.html>

Installation
------------

plpydbapi supports Python 2.6 and later, including Python 3.x, and
requires PostgreSQL 9.1 or later. Using `cursor.description` requires
PostgreSQL 9.2.

Just install it like any setuptools-enabled Python module, for example

python setup.py install

or use easy_install. Make sure you use the Python version that your
installation of PL/Python was built against.

Using
-----

Here is an example how to use it:

import plpydbapi

dbconn = plpydbapi.connect()
cursor = dbconn.cursor()
cursor.execute("SELECT ... FROM ...")
for row in cursor.fetchall():
plpy.notice("got row %s" % row)
dbconn.close()

Test suite
----------

[![Build Status](https://secure.travis-ci.org/petere/plpydbapi.png)](http://travis-ci.org/petere/plpydbapi)

There is a test suite in the test/ subdirectory. It uses the DB-API
compliance test framework from
<https://launchpad.net/dbapi-compliance>. So first fetch, er, clone,
er, branch yourself a copy of that

bzr branch lp:dbapi-compliance

into the current directory. If you have
[mr](http://kitenet.net/~joey/code/mr/), just run `mr up`.

If you are using Python 2.6, you also need the unittest2 package; with
Python 2.7 and later, the unittest module in the standard library is
enough.

Then run

python setup.py test

This will run the unittest suite inside the PostgreSQL server,
forwarding the output for the client to see.

If you have a complicated setup, such as multiple PostgreSQL versions
or nonstandard ports, use libpq environment variables such as PGHOST
and PGPORT to point the test suite driver to an instance it can use.
You can also look into the files setup.py and
test/run_test_plpydbapi_dbapi20.sql for some additional ways to tweak
the process.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

plpydbapi-0.20121018.tar.gz (6.6 kB view details)

Uploaded Source

File details

Details for the file plpydbapi-0.20121018.tar.gz.

File metadata

File hashes

Hashes for plpydbapi-0.20121018.tar.gz
Algorithm Hash digest
SHA256 12a59f30b4fc7621f0780cbae275fead1e0c71e0c0d749b4d5d8dee7ddab35a4
MD5 7f93c91dd45b37315b4cbdaee5400fa4
BLAKE2b-256 7ba5b66027be2d693d18437594ebed429cb9e65d7404ee1e4685aad6406eddac

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page