Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
193
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. TABLE testtable
  2. testcolumn1 | testcolumn2 | testcolumn3
  3. ------------+-------------+------------
  4. horse | cow | goat
  5. simple | code | test
  6. cant | figure | this
  7.  
  8.  
  9. conn = psycopg2.connect("dbname='test' user='me' password='pass'")
  10. cursor = conn.cursor()
  11. cursor.execute("select * from testtable")
  12. cursor_rows = cursor.fetchall()
  13. for row in cursor_rows:
  14. print(row['testcolumn2'])
  15.  
  16. # the result of the loop should be
  17. cow
  18. code
  19. figure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement