python -c "import psycopg2; print psycopg2.__version__"
http://initd.org/psycopg/docs/extensions.html#psycopg2.extensions.Diagnostics
sudo pip install psycopg2 --upgrade
Error: You need to install postgresql-server-dev-X.Y for building a server-side extension or libpq-dev for building a client-side application.
sudo apt-get install python-dev
sudo apt-get install postgresql-9.1
sudo apt-get install python-psycopg2
sudo apt-get install libpq-dev
http://initd.org/psycopg/docs/module.html#psycopg2.Error.diag
http://www.postgresql.org/docs/current/static/libpq-exec.html#LIBPQ-PQRESULTERRORFIELD