Guest User

Untitled

a guest
Jan 26th, 2018
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.88 KB | None | 0 0
  1. #UVindextime
  2. print "Todays' max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[0].uvIndexTime)
  3. day0uvindextime=datetime.datetime.fromtimestamp(boston.daily[0].uvIndexTime)
  4. print "Tomorrows' max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[1].uvIndexTime)
  5. day1uvindextime=datetime.datetime.fromtimestamp(boston.daily[1].uvIndexTime)
  6. print "Day 2 max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[2].uvIndexTime)
  7. day2uvindextime=datetime.datetime.fromtimestamp(boston.daily[2].uvIndexTime)
  8. print "Day 3 max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[3].uvIndexTime)
  9. day3uvindextime=datetime.datetime.fromtimestamp(boston.daily[3].uvIndexTime)
  10. print "Day 4 max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[4].uvIndexTime)
  11. day4uvindextime=datetime.datetime.fromtimestamp(boston.daily[4].uvIndexTime)
  12. print "Day 5 max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[5].uvIndexTime)
  13. day5uvindextime=datetime.datetime.fromtimestamp(boston.daily[5].uvIndexTime)
  14.  
  15. Todays' max UV index time is 2018-01-27 14:00:00
  16. Tomorrows' max UV index time is 2018-01-28 13:00:00
  17. Day 2 max UV index time is 2018-01-29 13:00:00
  18. Day 3 max UV index time is 2018-01-30 13:00:00
  19. Day 4 max UV index time is 2018-01-31 14:00:00
  20. Day 5 max UV index time is 2018-02-01 14:00:00
  21.  
  22. mariadb_connection = mariadb.connect(user='user', password='pw', database='UVdb')
  23. cursor = mariadb_connection.cursor()
  24. cursor.execute("CREATE TABLE IF NOT EXISTS uvtable (ts TIMESTAMP, Day0 DATETIME , Day1 DATETIME , Day2 DATETIME , Day3 DATETIME , Day4 DATETIME , Day5 DATETIME)")
  25. sql ="INSERT INTO uvtable (ts, Day0, Day1, Day2, Day3, Day4, Day5)"
  26. sql += "VALUES (NULL, %s, %s, %s, %s, %s, %s)"
  27. cursor.execute(sql,(day0uvindextime, day1uvindextime, day2uvindextime, day3uvindextime, day4uvindextime, day5uvindextime))
  28. print("Storing UV index time values")
  29. mariadb_connection.commit()
  30. mariadb_connection.close()
  31.  
  32. MariaDB [forecastdb]> select * from UVtable;
  33. +---------------------+--------+--------+--------+--------+--------+--------+
  34. | ts | Day0 | Day1 | Day2 | Day3 | Day4 | Day5 |
  35. +---------------------+--------+--------+--------+--------+--------+--------+
  36. | 2018-01-27 14:58:48 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
  37. | 2018-01-27 15:04:02 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
  38. | 2018-01-27 15:05:29 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
  39. | 2018-01-27 15:12:35 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
  40. | 2018-01-27 15:13:50 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
  41. | 2018-01-27 15:15:59 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
  42. | 2018-01-27 15:16:54 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
  43. | 2018-01-27 15:18:10 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
Add Comment
Please, Sign In to add comment