Question: Next, you must develop a Python module in a PY file, using object-oriented programming methodology, to enable CRUD functionality for the database. To support code
- Next, you must develop a Python module in a PY file, using object-oriented programming methodology, to enable CRUD functionality for the database. To support code reusability, your Python code needs to be importable as a module by other Python scripts. Develop a CRUD class that, when instantiated, provides the following functionality:
- A Create method that inserts a document into a specified MongoDB database and collection
- Input -> argument to function will be a set of key/value pairs in the data type acceptable to the MongoDB driver insert API call.
- Return -> True if successful insert, else False.
- A Read method that queries for document(s) from a specified MongoDB database and specified collection
- Input -> arguments to function should be the key/value lookup pair to use with the MongoDB driver find API call.
- Return -> result in cursor if successful, else MongoDB returned error message.
- An Update method that queries for and changes document(s) from a specified MongoDB database and specified collection
- Input -> arguments to function should be the key/value lookup pair to use with the MongoDB driver find API call. Last argument to function will be a set of key/value pairs in the data type acceptable to the MongoDB driver insert API call.
- Return -> result in JSON format if successful, else MongoDB returned error message.
- A Delete method that queries for and removes document(s) from a specified MongoDB database and specified collection
- Input -> arguments to function should be the key/value lookup pair to use with the MongoDB driver find API call.
- Return -> result in JSON format if successful, else MongoDB returned error message.
- A Create method that inserts a document into a specified MongoDB database and collection
- Finally, you must test your Python module to make sure that it works. To do this, create a Python script that imports your CRUD Python module to call and test all instances of CRUD functionality. This script should be created in a separate Jupyter Notebook (IPYNB) file, and should import and instantiate an object from your CRUD library to effect changes in MongoDB. Be sure to use the username and password for the aacuser account for authentication when instantiating the class. After creating your script, execute it in Jupyter Notebook and take screenshots of the commands and their execution. These screenshots will later be included in your README file.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
