Fetch all rows after query : PostgreSQL : Database PYTHON TUTORIALS


PYTHON TUTORIALS » Database » PostgreSQL »

 

Fetch all rows after query


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

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

rows = cur.fetchall()
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