skip to navigation
skip to content

Not Logged In

psycopg2cffi 2.6.1

.. image::

An implementation of the psycopg2 module using cffi. The module is currently compatible with Psycopg 2.5.

You can install psycopg2cffi from pypi:

pip install psycopg2cffi

Or from source:

python develop

Installation requirements are the same as for psycopg2 - you must have libpq headers, pg_config somewhere on your $PATH. Installation was tested on Ubuntu 12.04 and CentOS (RHEL 5.0). It should be possible to make it work on Windows, but I did not even test it.

This module works under CPython 2.6+, CPython 3.2+, PyPy 2 and PyPy 3 (PyPy version should be at least 2.0, which is ancient history now).

To use this package with Django or SQLAlchemy invoke a compatability hook (for example, from in case of django, or from a file in site-packages of your virtual env):

from psycopg2cffi import compat

This will map psycopg2cffi to psycopg2.

Submit issues to

If you notice that psycopg2cffi under PyPy is noticably slower than psycopg2 under CPython, submit this to the issues too - it should not be the case.

This is a port of (Michael van Tellingen port of Alex Gaynor’s rpython port ( of psycopg2 to python + ctypes) to cffi.

The main motivation for a port was speed - the writeup with benchmarks is here:


To run tests, install pytest and run them with:

py.test psycopg2cffi

You can also run Django tests. You need to checkout django source, add psycopg2 compat as described above, and, from the root of the django checkout:

PYTHONPATH=`pwd` ./tests/ \

In case of problems with django tests, see official django docs

Release notes

2.6.1 (08 Feb 2015)

Fixing things that were broken in 2.6.0:

  • Fix issue #31 - bigint on 32-bit
  • Fix issue #32 - register_type and unicode

2.6.0 (24 Jan 2015)

  • Python 3 support
  • A bit faster reading of int, long, float, double fields

2.5.1 (14 May 2014)

  • Little bufixes

2.5.0 (3 Sep 2013)

  • Bufixes and a lot of compatability work by Daniele Varrazzo

Older releases lack release notes, first release of psycopg2cffi around Nov 2012.

File Type Py Version Uploaded on Size
psycopg2cffi-2.6.1.tar.gz (md5) Source 2015-02-08 68KB
  • Downloads (All Versions):
  • 145 downloads in the last day
  • 1139 downloads in the last week
  • 5200 downloads in the last month