Tuesday, December 29, 2009

Install PostgreSQL on Ubuntu with python support

Recently I need it to install PostgreSQL for Django.
Here is how I did it.

$ sudo apt-get install postgresql python-psycopg pgadmin3
Note that pgadmin3 is a graphical app so unless you have Gnome or KDE installed you don't need it.

After you install everything you will need to set postgresql password.
$ sudo passwd postgres
$ su postgres
$ psql template1
Last command will open PostgreSQL shell where you can type:
ALTER USER postgres WITH ENCRYPTED PASSWORD 'password';
Thats all.

You can verify it by going to the python shell and importing it.
$ python
>>> import psycopg
>>> psycopg.apilevel
'2.0'
>>>

If you get this far than everything isup and running.

No comments: