Tolentino - 4-1 Milestone

docx

School

Southern New Hampshire University *

*We aren’t endorsed by this school

Course

340

Subject

Computer Science

Date

Feb 20, 2024

Type

docx

Pages

3

Uploaded by UltraCamelMaster345

Report
Raphael Tolentino CS340 Prof. Perkins 11 Feb 2024 Python Scripts
Mongolmport £ P b ( (b rt NN QANNC QN
CRUD Functionality #implement the C in CRUD def create(self, data): if data is not None: insert = self.database.animals.insert(data) if insert != 0O: return True else: return False else: raise Exception("Nothing to save, because data parameter is empty"”) #implement the R in CRUD def read(self, criteria=None): if criteria is not None: data = self.database.animals.find(criteria,{"” id": False}) for document in data: print(document) else: data = self.database.animals.frind({}, {" id": False}) return datal #implement the U in CRUD def update(self, searchData, updateData): if searchData is not None: result = self.database.animals.update many(searchData, { "$set”: updateData }) else: return "{}" return result.raw result #implement the D in CRUD def delete(self, deleteData): if deleteData is not None: result = self.database.animals.delete many(deleteData) else: return "{}" return result.raw result Script Testing In [2]: animals = Animal Shelter("aacuser", "RtE6") In [3]: print(animals.create ({ “'age upon outcome': "1 years", «'animal id': "test", «'animal type': "Dog", “'breed': "Tamaskan Dog", «'color': "Grey and Gold", «'date of birth': "2024-02-08", «'dateTime': "2024-02-08 20:54:00", “'month and year': "2024-02-08T720:54:00", “'name': "Ghost", “'ouctome subtype': "", “'outcome type': "Adoption", “'sex_upon outcome': "Neutered Male", «'location lat': 43.021380, «'location long': -71.278839, “'age upon outcome in weeks': 52.9215277777778}))
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help