Advertisement
Guest User

Untitled

a guest
Sep 11th, 2017
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. #!/usr/bin/python3
  2. import psycopg2
  3.  
  4. conn = psycopg2.connect(
  5. database="sensordb",
  6. user="postgres",
  7. password="raspDB",
  8. host="127.0.0.1",
  9. port="5432"
  10. )
  11.  
  12. cur = conn.cursor()
  13. cur.execute("SELECT * FROM sensortable")
  14. rows = cur.fetchall()
  15. conn.close()
  16.  
  17. for row in rows:
  18. resultDict = {
  19. "ID" : row[0],
  20. "NAME" : row[1],
  21. "TYPE" : row[2],
  22. "VALUE" : row[3],
  23. "DATE" : str(row[4])
  24. }
  25. print(resultDict)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement