diff --git a/python/01_connect_database.ipynb b/python/01_connect_database.ipynb index c19abf6..166ef17 100644 --- a/python/01_connect_database.ipynb +++ b/python/01_connect_database.ipynb @@ -79,9 +79,7 @@ "#Database name\n", "db = client[\"library\"]\n", "\n", - "books = db[\"books\"]\n", - "\n", - "client.close()" + "books = db[\"books\"]" ] }, { diff --git a/python/103_aggregation_pipeline_lookup.ipynb b/python/103_aggregation_pipeline_lookup.ipynb index b276a3c..cf10f73 100644 --- a/python/103_aggregation_pipeline_lookup.ipynb +++ b/python/103_aggregation_pipeline_lookup.ipynb @@ -73,6 +73,31 @@ "for f in cursor:\n", " print(f\"author: {f}.\")" ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Challenges" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "### Fetch books with their associated reviews\n", + "\n", + "[Solution here](https://mongodb-developer.github.io/sql-to-query-api-lab/docs/aggregation/lookup#-1-fetch-books-with-their-associated-reviews)" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# Type your code here" + ] } ], "metadata": { diff --git a/python/10_find.ipynb b/python/10_find.ipynb index 4ef8639..1c62dc7 100644 --- a/python/10_find.ipynb +++ b/python/10_find.ipynb @@ -74,7 +74,7 @@ "metadata": {}, "outputs": [], "source": [ - "results = books.find({ \"year\": { \"$gt\" : 2008 }})\n", + "results = books.find({ \"year\": { \"$gt\" : 2008 }}).limit(10)\n", "\n", "for f in results:\n", " print(f) " diff --git a/python/20_project_sort_limit.ipynb b/python/20_project_sort_limit.ipynb index ebe9fe6..866097a 100644 --- a/python/20_project_sort_limit.ipynb +++ b/python/20_project_sort_limit.ipynb @@ -122,7 +122,7 @@ " \"pages\": 1\n", "}\n", "\n", - "cursor = books.find({}, projection).sort(\"pages\", -1).skip(4).limit(5)\n", + "cursor = books.find({}, projection).sort(\"pages\", -1).skip(4).limit(10)\n", "\n", "for book in cursor:\n", " print(f\"{book['title']}\")" diff --git a/python/30_insert.ipynb b/python/30_insert.ipynb index 5466217..f43de5d 100644 --- a/python/30_insert.ipynb +++ b/python/30_insert.ipynb @@ -96,7 +96,6 @@ "metadata": {}, "outputs": [], "source": [ - "from pymongo import MongoClient\n", "from bson.objectid import ObjectId\n", "\n", "#Get the book by its _id from the previous step\n",