def action_on_a_page_single_doc(page):
    docs = [row.doc for row in page]
    for doc in docs:
        doc["tiid"] = doc["_id"]
        try:
            doc["last_update_run"]
        except __HOLE__:
            doc["last_update_run"] = None        

        print "try"
        try:
            print doc["tiid"]
            cur.execute("""INSERT INTO items(tiid, created, last_modified, last_update_run) 
                            VALUES (%(tiid)s, %(created)s, %(last_modified)s, %(last_update_run)s)""", doc)
            #conn.commit()
        except psycopg2.IntegrityError:
            print "row already exists"
            mypostgresdao.conn.rollback()
        except:
            mypostgresdao.conn.rollback()
        finally:
            pass
dataset/ETHPy150Open Impactstory/total-impact-core/extras/db_housekeeping/postgres_mirror.py/action_on_a_page_single_doc