Fetch row one by one : PostgreSQL : Database PYTHON TUTORIALS


PYTHON TUTORIALS » Database » PostgreSQL »

 

Fetch row one by one


import psycopg
dbh = psycopg.connect('dbname=dbname user=username')
print "Connection successful."

cur = dbh.cursor()
cur.execute("SELECT * FROM myTable")
cur.arraysize = 2

while 1:
    row = cur.fetchone()
    if row is None:
        break
    print row
    
dbh.close()



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo Database
» PostgreSQL