import psycopg2 #module le plus courant pour la connexion à PostgreSQL
conn = psycopg2.connect("dbname='testpostgis'host='localhost' user='moi'")
cur = conn.cursor()
cur.execute("""SELECT astext(the_geom) from testpoly;""")
listpoly = cur.fetchall()
for i in listpoly:
print i
('POLYGON((0.09094470046083 0.807557603686636,0.141635944700461 0.80147465437788,0.360622119815668 0.702119815668203,0.240990783410138 0.548018433179723,0.086889400921659 0.584516129032258,0.054447004608295 0.742672811059908,0.09094470046083 0.807557603686636))',)
('POLYGON((0.275460829493088 0.793364055299539,0.537027649769585 0.813640552995392,0.417396313364055 0.592626728110599,0.226797235023042 0.67778801843318,0.226797235023042 0.744700460829493,0.275460829493088 0.793364055299539))',)
cur.close()
cur = conn.cursor()
query = "SELECT nom, AsText(the_geom), Srid(the_geom) FROM testpoly where nom='%s'" % 'test1'
cur.execute(query)
poly = cur.fetchone()
print poly
('test1', 'POLYGON((0.09094470046083 0.807557603686636,0.141635944700461 0.80147465437788,0.360622119815668 0.702119815668203,0.240990783410138 0.548018433179723,0.086889400921659 0.584516129032258,0.054447004608295 0.742672811059908,0.09094470046083 0.807557603686636))', 4326)