Are you able to assist me to for connecting to my postgresql database with python? I have to create graphic interface with python that will visualize shapefile data from the database (i've about 50 polygons in shapefile format for the reason that database). Are you able to assist me to with creating such application? I'm begginer in python.

For interacting using the database, use psycopg2. It's quick, simple and easy , efficient if you're acquainted with fundamental DB concepts.

There are several options came from here. You should use shpUtils, which is designed to be considered a nice package for parsing shapefiles. After that you can visualize the information using numerous python graphics packages, like pil.

Pil at work

PIL image source code here.

Every option suits another need, based on that which you define as "create graphic interface". If you want to produce a simple graphics output, build the polygons from text using among the graphics utilities pointed out above. If you want to produce a professional-searching image, use mapnik (pointed out in certain other solutions), which easily reads shapefiles. If you want to produce a completely functional GUI, it's most likely not really a beginner's task - you can start with programming fundamental GUI programs before diving into shapefiles and polygons.

If, however, you need to simply see the polygons - skip python and merely use qgis, that will effortlessly visualize your polygons. Additionally, it has a number of other nice features, like colors, zooms and so forth. QGis example from SF.net

I'd approach this by breaking up into more compact problems and fixing all of them

a) How do you connect with a postgresql database with python?

http://stackoverflow.com/search?q=postgresql+database+python - Appears like psycopg2 is a great option as Adam Matan recommended.

b) Drawing shapefile data in python

http://stackoverflow.com/questions/1776511/postgresql-and-python-or-pphp

Mapnik is ideal for drawing maps. It may handle various formats and shapefiles, too. So far as Yes, it will also support PostgreSQL (a minimum of PostGIS).

And least although not last: it arrives with a Python interface (see Getting started)

I cant use any software like quantum gis, and that i cant use mapnik, too. It's work for my college. I did not learn how to draw individuals shapefiles in python. I attached to database:

import psycopg2
conn = psycopg2.connect("dbname='***' user='***' host='***' password='***'")
print 'Succesfully connected'

cur = conn.cursor()
cur.execute("""SELECT astext(the_geom) from buildings;""")
listpoly = cur.fetchall()
conn.close()

I dont understand how to continue. I must use matplotlib.