So I created a Gui with a field where the user inserts the id of a document and other information and then inserts it in the database. He can also search for the document using the correct id.(Search for documents that exist works just fine) What I want to do is display an error message when the users enters an id and no corresponding document is found. This is just a piece of the code.
mongoHost= "localhost"
myclient = pymongo.MongoClient("mongodb://localhost:27018/")
db = myclient["realEstateDB"]
mycol = db["houses"]
idquestion= Label(frame,text="Property ID:",bg="#D3D3D3",fg="black", font='Helvetica 13 bold')
idquestion.grid(row=2,column=1)
idfield= Entry(frame)
idfield.grid(row=2,column=2,padx=10, pady=10)
id=idfield.get()
for mydict in mycol.find({"Property ID": id}):
if mydict[{"Property ID": id}] not in mycol:
message= Label(frame2, text='No such entry', bg="#D3D3D3", fg="black",font='Helvetica 13 bold')
message.pack()