I have a postgres
database table with nearly 700k records. I would want to have a python script that fetches the records one-by-one at 5seconds interval until the last record.
How do I go about it?
Advertisement
Answer
Do you need anything more than that?
from time import sleep import psycopg2 conn = psycopg2.connect("dbname=test user=postgres") cur = conn.cursor() cur.execute("SELECT * FROM table") for record in cur: # process record sleep(5) cur.close() conn.close()