Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit fa401c0

Browse files
Addition of new column to determine job triggerred is manual or scheduled task
1 parent 570b5a6 commit fa401c0

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

‎Excersise/GoldRate/HelloWorld.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
import requests
1616
from datetime import date
17+
from datetime import datetime
1718
from bs4 import BeautifulSoup
1819

1920

@@ -96,7 +97,19 @@ def insertRecord(con):
9697
sample.insert(3, gold_rate['22K']['8g'])
9798
sample.insert(4, gold_rate['22K']['1g'])
9899

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)
100113

101114
#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] +"');"
102115
cursor = con.cursor()
@@ -126,5 +139,4 @@ def disconnectDB(con):
126139
time.sleep(10)
127140
print("Good Bye!")
128141

129-
time.sleep(3)
130-
142+
time.sleep(3)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /