How to break the while loop, when the condition is true?
I tried using break under an if statement, but it's not working.
def proallocate():
while True:
conn = sqlite3.connect('database.db')
cur = conn.cursor()
pid = cur.execute("SELECT project_id FROM Upload WHERE status= ?", ("NULL",))
for pd in pid:
a = str(pd)
projectid = re.sub('[\(\),\{\}<>]', '', a)
url = "https://picture-us.amazon.com/colorauthor/view/"+projectid+""
print(url)
req = requests.Session()
resp = req.get(url, auth=HTTPKerberosAuth(mutual_authentication=False), verify="./amazon_dev_certs.pem")
soup = BeautifulSoup(resp.text, 'html.parser')
project_status_latest = soup.find_all('tr')[-1].get_text()
if ("Project Ready" in project_status_latest):
proid[0] = projectid
print(proid[0])
else:
cur.execute("UPDATE Upload SET status = ? WHERE project_id = ?", ("Reserved", projectid))
conn.commit()
I expect that the loop should stop when the if condition passes.