Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #UVindextime
- print "Todays' max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[0].uvIndexTime)
- day0uvindextime=datetime.datetime.fromtimestamp(boston.daily[0].uvIndexTime)
- print "Tomorrows' max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[1].uvIndexTime)
- day1uvindextime=datetime.datetime.fromtimestamp(boston.daily[1].uvIndexTime)
- print "Day 2 max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[2].uvIndexTime)
- day2uvindextime=datetime.datetime.fromtimestamp(boston.daily[2].uvIndexTime)
- print "Day 3 max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[3].uvIndexTime)
- day3uvindextime=datetime.datetime.fromtimestamp(boston.daily[3].uvIndexTime)
- print "Day 4 max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[4].uvIndexTime)
- day4uvindextime=datetime.datetime.fromtimestamp(boston.daily[4].uvIndexTime)
- print "Day 5 max UV index time is %s" % datetime.datetime.fromtimestamp(boston.daily[5].uvIndexTime)
- day5uvindextime=datetime.datetime.fromtimestamp(boston.daily[5].uvIndexTime)
- Todays' max UV index time is 2018-01-27 14:00:00
- Tomorrows' max UV index time is 2018-01-28 13:00:00
- Day 2 max UV index time is 2018-01-29 13:00:00
- Day 3 max UV index time is 2018-01-30 13:00:00
- Day 4 max UV index time is 2018-01-31 14:00:00
- Day 5 max UV index time is 2018-02-01 14:00:00
- mariadb_connection = mariadb.connect(user='user', password='pw', database='UVdb')
- cursor = mariadb_connection.cursor()
- cursor.execute("CREATE TABLE IF NOT EXISTS uvtable (ts TIMESTAMP, Day0 DATETIME , Day1 DATETIME , Day2 DATETIME , Day3 DATETIME , Day4 DATETIME , Day5 DATETIME)")
- sql ="INSERT INTO uvtable (ts, Day0, Day1, Day2, Day3, Day4, Day5)"
- sql += "VALUES (NULL, %s, %s, %s, %s, %s, %s)"
- cursor.execute(sql,(day0uvindextime, day1uvindextime, day2uvindextime, day3uvindextime, day4uvindextime, day5uvindextime))
- print("Storing UV index time values")
- mariadb_connection.commit()
- mariadb_connection.close()
- MariaDB [forecastdb]> select * from UVtable;
- +---------------------+--------+--------+--------+--------+--------+--------+
- | ts | Day0 | Day1 | Day2 | Day3 | Day4 | Day5 |
- +---------------------+--------+--------+--------+--------+--------+--------+
- | 2018-01-27 14:58:48 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
- | 2018-01-27 15:04:02 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
- | 2018-01-27 15:05:29 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
- | 2018-01-27 15:12:35 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
- | 2018-01-27 15:13:50 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
- | 2018-01-27 15:15:59 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
- | 2018-01-27 15:16:54 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 | 999.99 |
- | 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