Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- TABLE testtable
- testcolumn1 | testcolumn2 | testcolumn3
- ------------+-------------+------------
- horse | cow | goat
- simple | code | test
- cant | figure | this
- conn = psycopg2.connect("dbname='test' user='me' password='pass'")
- cursor = conn.cursor()
- cursor.execute("select * from testtable")
- cursor_rows = cursor.fetchall()
- for row in cursor_rows:
- print(row['testcolumn2'])
- # the result of the loop should be
- cow
- code
- figure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement