Adjust the connect() call below for your database : PostgreSQL : Database PYTHON TUTORIALS


PYTHON TUTORIALS » Database » PostgreSQL »

 

Adjust the connect() call below for your database


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:
    rows = cur.fetchmany()
    print "Obtained %d results from fetchmany()." % len(rows)
    if not len(rows):
        break

    for row in rows:
        print row
    
dbh.close()



Leave a Comment / Note


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


PYTHON TUTORIALS

 Navioo Database
» PostgreSQL