how to itirate over Postgresql rows in python script? : I'm writing a script which takes row from DB and iterate over the rows.

In MySQL I would do:

    import MySQLdb
    db_mysql=MySQLdb.Connect(user=...,passwd=...,db=..., host=...)
    cur = db_mysql.cursor(MySQLdb.cursors.DictCursor)
    cur.execute ("""SELECT X,Y,Z FROM tab_a""")
    for row in crs.fetchall () :
         do things...

But I don't know how to do it in PostgreSQL as PostgreSQL doesn't have `cursors`.
Basicly this question could be how to translate the above MySQL code to work with PostgreSQL.

This is what I have so far.

    import pg
    pos = pg.connect(dbname=...,user=...,passwd=...,host=..., port=...)
    pos.query("""SELECT X,Y,Z FROM tab_a""")

How do I iterate over this query results?