I have created local SAM Lambda app on my machine and local MongoDB. My intention is to create a connection between SAM app and MongoDB. You can see the code:
import json
import pymongo
client = pymongo.MongoClient('mongodb://127.0.0.1:27017/')
mydb = client['Employee']
def lambda_handler(event, context):
information = mydb.employeeInformation
record = {
'FirstName' : 'Rehan',
'LastName' : 'CH',
'Department' : "IT"
}
information.insert_one(record)
print("Record added")
return {
"statusCode": 200,
"body": json.dumps(
{
"message": "Finally my local lambda worked.",
}
),
}
I have added the python library "PyMongo" using Pip install pymongo. But when I execute this SAM Lambda app, it throws an error that says:
{"errorMessage": "Unable to import module 'app': No module named 'pymongo'", "errorType": "Runtime.ImportModuleError", "requestId": "d9a99323-2331-4228-s5f6-dd2e18d6a85e", "stackTrace": []}
Although, I have added the python library to the folder as you can see in the following picture:

Please tell me how to add libraries in the locally created SAM app.
I have added libraries on the AWS console but in the local environment, I don't know where to add these libraries.