Posts

Showing posts with the label MongoDB

How to fix ModuleNotFoundError - No module named pymongo in Notebook

Image
One common issues while working with python or spark is getting error message which says - module not found. Module not found here points that proper configuration or installation is required in respect to libray level. Once this is done, application will able to find my required module. For example, while using below code in Fabric Notebook and trying to connect with MongoDB database and display records, getting no module found error message. Running the code, it is throwing error - ModuleNotFoundError - No module named pymongo To fix the abobe issue, it is required to install the required libries. #install the required packages ! pip install pymongo ! pip install certifi Once done, Azure notebook now able to connect with Mongo database, and getting the confirmation log from Azure. Collecting pymongo Downloading pymongo-4.6.3-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (676 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 676.9/676.9 kB 17.3 MB/s eta 0:00:00 a 0:00...

.NET WebAPI calling Mongo DB

Image
 This is basic WebAPI project created using .NET 7.0 version and it makes call to MongoDB database collection sitting in Mongo Cloud. The DB configuration is in appsettings.json file. Below is the project structure - simple is the best :) You can create simple WebApI project using VS Studio 2022 on .NET 7.0 and then replace the code of individual pages from below. Please create the folders i.e. Models , Controller , and Services as shows in above picture  Please make sure to update DB configuration in appsettings.json according to your setup. The other important thing is to install MongoDB Driver, Core etc from Nuget Package. Page: AppSettings.json {   "MovieStoreDatabase": {     "ConnectionString": "mongodb+srv://m001-stu01-monb-basics@box.hongodb.net/test",     "DatabaseName": "video",     "DBCollectionName": "movieDetails"   },   "Logging": {     "LogLevel": {       "Default": "...