1:58 AM PostgreSQL with Python at Amazon Elastic Cloud |
I have Python 2.6.7 and PostgreSQL 8.4.9 on my ec2 machine - all "stock". When it came to interacting between those two, I opted for psycopg2 Python module, which implements Python DB API 2.0 specifications. The module seems to be quite mainstream, timely updated, and compliance with standards is a positive thing in my eyes. :-) My current PostgreSQL install has [ec2-user@ip ~]$ rpm -qa | grep postgres postgresql-libs-8.4.9-1.13.amzn1.x86_64 postgresql-8.4.9-1.13.amzn1.x86_64 postgresql-server-8.4.9-1.13.amzn1.x86_64In order to get the programmatic access, we need to get libpq-dev. Couldnot think of anything but libpq from postgresql-devel: [ec2-user@ip ~]$ sudo yum install postgresql-devel The other pre-requisite - python-dev, seemed to be there already (I might have installed it before): [ec2-user@ip ~]$ rpm -qa | grep python-dev python-devel-2.6-1.19.amzn1.noarch The last requirement is to have pg_config in the PATH. [ec2-user@ip ]$ which pg_config /usr/bin/pg_configconfirmed - it is. I installed from source as they claim easy_install would not resolve these dependencies anyway; but I am pretty confident that sudo easy_install psycopg2 would have worked just fine. To install from the source, I downloaded the archive from the Download page. It happened to be the source package for psycopg2-2.4.4 - http://initd.org/psycopg/tarballs/PSYCOPG-2-4/psycopg2-2.4.4.tar.gz. Then it was easy: [ec2-user@ip ]$ tar -zxf psycopg2-2.4.4.tar.gz [ec2-user@ip ]$ cd psycopg2-2.4.4 [ec2-user@ip ]$ sudo python setup.py install The install command ended up with Writing /usr/lib64/python2.6/site-packages/psycopg2-2.4.4-py2.6.egg-info, and I could not spot errors, so I assume psycopg2-2.4.4 is installed just fine. Let's give it a smoke test: [ec2-user@ip-10-64-54-250 psycopg2-2.4.4]$ python Python 2.6.7 (r267:88850, Jun 4 2011, 04:34:02) [GCC 4.4.4 20100726 (Red Hat 4.4.4-13)] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import psycopg2 >>>Well, so far so good (at least it imports). Additional info
|
|
Total comments: 0 | |