-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #79 from AccelerationConsortium/update-1.5
Update 1.5
- Loading branch information
Showing
12 changed files
with
1,988 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"# Reading Data from MongoDB via AWS Lambda\n", | ||
"\n", | ||
"This notebook demonstrates how to read data from MongoDB using an AWS Lambda function and API Gateway." | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Setup\n", | ||
"\n", | ||
"First, let's install the required libraries and import them." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"!pip install requests\n", | ||
"import requests\n", | ||
"import json" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Configuration\n", | ||
"\n", | ||
"Replace the placeholder values with your actual AWS API Gateway URL and API Key." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"AWS_API_GATEWAY_URL = \"https://your-api-gateway-url.execute-api.region.amazonaws.com/stage/resource\"\n", | ||
"AWS_API_KEY = \"your-api-key\"" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Function to Read Data\n", | ||
"\n", | ||
"Let's create a function to read data from MongoDB via our AWS Lambda function." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"def read_data_from_mongodb(query={}):\n", | ||
" headers = {\n", | ||
" \"x-api-key\": AWS_API_KEY,\n", | ||
" \"Content-Type\": \"application/json\"\n", | ||
" }\n", | ||
" \n", | ||
" response = requests.post(AWS_API_GATEWAY_URL, headers=headers, json=query)\n", | ||
" \n", | ||
" if response.status_code == 200:\n", | ||
" return response.json()\n", | ||
" else:\n", | ||
" print(f\"Error: {response.status_code}, {response.text}\")\n", | ||
" return None" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Reading Data\n", | ||
"\n", | ||
"Now, let's use our function to read data from MongoDB." | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Read all documents\n", | ||
"result = read_data_from_mongodb()\n", | ||
"print(json.dumps(result, indent=2))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"# Read documents with a specific query\n", | ||
"query = {\"course_id\": \"DEMO101\"}\n", | ||
"result = read_data_from_mongodb(query)\n", | ||
"print(json.dumps(result, indent=2))" | ||
] | ||
}, | ||
{ | ||
"cell_type": "markdown", | ||
"metadata": {}, | ||
"source": [ | ||
"## Conclusion\n", | ||
"\n", | ||
"This notebook demonstrated how to read data from MongoDB using an AWS Lambda function through an API Gateway. Remember to keep your API key secure and not share it publicly." | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"kernelspec": { | ||
"display_name": "Python 3", | ||
"language": "python", | ||
"name": "python3" | ||
}, | ||
"language_info": { | ||
"codemirror_mode": { | ||
"name": "ipython", | ||
"version": 3 | ||
}, | ||
"file_extension": ".py", | ||
"mimetype": "text/x-python", | ||
"name": "python", | ||
"nbconvert_exporter": "python", | ||
"pygments_lexer": "ipython3", | ||
"version": "3.8.5" | ||
} | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 4 | ||
} |
Submodule 3.4-Mobile-robotics
added at
97a19d
Empty file.
Oops, something went wrong.