14
14
15
15
import requests
16
16
from datetime import date
17
+ from datetime import datetime
17
18
from bs4 import BeautifulSoup
18
19
19
20
@@ -96,7 +97,19 @@ def insertRecord(con):
96
97
sample .insert (3 , gold_rate ['22K' ]['8g' ])
97
98
sample .insert (4 , gold_rate ['22K' ]['1g' ])
98
99
99
- workingQuery = "INSERT INTO `world`.`daily_gold_rates` (`todays_date`, `twentyFour_carot_eight_grams`,`twentyFour_carot_one_gram`, `twentyTwo_carot_eight_grams`, `twentyTwo_carot_one_gram` ) VALUES ('" + str (todaysDateFormatToDB ) + "','" + gold_rate ['24K' ]['8g' ] + "'," + "'" + gold_rate ['24K' ]['1g' ]+ "'," + "'" + gold_rate ['22K' ]['8g' ] + "'," + "'" + gold_rate ['22K' ]['1g' ] + "'" + ");"
100
+ # Check current time, act accordingly.
101
+ curremtTime = datetime .now ()
102
+ curremtTime = curremtTime .strftime ("%H:%M" )
103
+ print (curremtTime )
104
+
105
+ if (curremtTime == "12:34" ):
106
+ infoSource = "Scheduled Job"
107
+ else :
108
+ infoSource = "Manual Trigger"
109
+
110
+ workingQuery = "INSERT INTO `world`.`daily_gold_rates` (`todays_date`, `twentyFour_carot_eight_grams`,`twentyFour_carot_one_gram`, `twentyTwo_carot_eight_grams`, `twentyTwo_carot_one_gram`, `info_source` ) VALUES ('" + str (todaysDateFormatToDB ) + "','" + gold_rate ['24K' ]['8g' ] + "'," + "'" + gold_rate ['24K' ]['1g' ]+ "'," + "'" + gold_rate ['22K' ]['8g' ] + "'," + "'" + gold_rate ['22K' ]['1g' ] + "','" + infoSource + "');"
111
+
112
+ print (workingQuery )
100
113
101
114
#something3 = "INSERT INTO `world`.`daily_gold_rates` (`todays_date`,`twentyFour_carot_eight_grams`,`twentyFour_carot_one_gram`,`twentyTwo_carot_eight_grams`,`twentyTwo_carot_one_gram`) VALUES (" + "'" + sample[0] +"'," + "'" + sample[1] + "','" + sample[2] + "','" + sample[3] +"','" + sample[4] +"');"
102
115
cursor = con .cursor ()
@@ -126,5 +139,4 @@ def disconnectDB(con):
126
139
time .sleep (10 )
127
140
print ("Good Bye!" )
128
141
129
- time .sleep (3 )
130
-
142
+ time .sleep (3 )
0 commit comments