Tutorial 3- How To Connect Python With MongoDb- Pymongo Installation

Krish Naik · Beginner ·🛠️ AI Tools & Apps ·6y ago

Key Takeaways

Connects Python with MongoDB using PyMongo installation

Full Transcript

Oh on my name is Krishna I'm a loop to my youtube channel so guys today in this particular video I will actually show you how you can integrate Python with MongoDB how you can create databases collections and remember guys this is the part third tutorial my previous tutorial have actually shown you how to be install the MongoDB and how you can actually create you know databases connection with the help of my ODB shell right now in this particular video and show you how you can do it with Python programming language guys the first thing that you have to do if you want to actually work with by then along with MongoDB is that first of all install go and install a library which is called as I'm so open your underground and if you are to open it just go to start click on the come on and just type the command for this pip install unify move I said because this is the library which will help us to connect with the MongoDB and for this I'll just execute it and only have installed it so imma get the same s is saying that it has already been installed so to let the installation happen okay the requirement is already satisfied over here so I need not worry about it and it is already installed I'm just going to take this event now let's start how we should basically go and remember guys first of all the first thing that we should worry about is creating a database right or that I told you first of all I have to import something so this is my this is this is my library which has helped me to interact with the Moga TB and help us to create databases you know or collections and everything so first of all I am going to input my number and the next thing that I am going to do is that I'm just going to create a client basically my mo buddy be flying I am going to say [Music] remember this client will be interacting with our Mammootty like here I'm going to write pymongo with with MongoDB oh sorry not MongoDB mobile client and here I have to actually give my connection right remember guys by default um whenever we are running MongoDB in our local server by default the the IP that is there actually a second source to localhost so it will be having one twenty seven point zero one and remember guys one more thing that the port will actually be assigned and default port is assigned as zero one seven two seven zero one seven you can change this you can also apply password so you can give a username and password also which I'm showing upcoming tutorials and this is basically my whole complete IP address and what I'm going to do is is what you have to do is that you also have to give a protocol or and protocol that is used is something called a small body this is the protocol that is used oh sorry this is me this is my protocol this is my IP address where I'm actually connecting and this is basically my fault okay I'm repeating this is my protocol this is my IP address and this is my port number how pretty my simple have done this now all I have to do is that execute this too and see whether it is executing correctly or not and I can see in my console how let us go to the next slide now in the next line since I have created my mom would he be client how I can actually go and create my database how do you create my database so what I'm going to do is that first of all I'm just going to say this as my DB and I'm creating a variable and I'll just write it as climb off and remember this I can write climb dot my database name apart from that I can also give like this but I want to create my employee database so this is my database that I want appear I just write client of employee and I just executed before it if there is no database of this particular name it will create this particular case it will just be using the older one but this now my database is actually created in the moment if you know you may be thinking that how you check whether it has got created or not okay for the advertiser what I would like to suggest is that I hope in my previous video I've told you to basically install you know MongoDB compass which is pretty much important so for that what I'm going to do is that first of all I'm going to show you this mobile to become positive how this is how my momma Dee compass looks like and I cannot see any databases that is got created with the help of this particular name so make sure that I always remember guys as soon as you create a database automatically not get created unless and until you don't add collections inside it it will not just create this particular database Omega ok I'm just going to remove this and again we'll come back to this ok now what I'm going to do is that quickly I'll start creating my collections so I'll just save it as suppose I'll say information so I'm basically going to create a collection my DB and I want to give the collection name as employee info so this is how so this will basically do a collection collection basically means like if I consider mice my sequel order collection is just if I just be equal over there it will be like a name of a table okay so this is my connection name my information and let me just execute this ah the next thing that that is remaining is that I need to start inserting records from here right no Python program and remember guys all the records that are stored in the collection is in the form of JSON documents so I have to actually make a JSON format away in the form of a bank and just write it as records and here I'll create traditionally it has additionally but it will be in the form of Kiba okay so first in from just go to write it as first name or : this is Freddy my first field is ready I'm going to say class in holon Hank okay perfect this is also done and make sure that you give this and then I'll basically say in which department do I work so suppose if I write department and I'll see Alex this is the department I believe okay let me just execute quickly this particular stuff this code what do you have to do is that I will just be using this formation right dot and I have I guess I have one well here I just created one record or one caption basically one collection one one JSON document which I'm going to put that into my collection right so here I'm just going to give my record once I execute this you'll be able to see that this particular insert one result at this particular memory location has been done and let me just go back to buy more would he be client and see whether it has got just go over here and click on refresh as soon as I clicked on refresh you can see that my data will be present over here so here is my first name last name Department antics no simple and you could see that how the help of the spine now go right this things I have actually happened I suppose if I want to give multiple records or I am doing sort at a time multiple how do it so always remember I have to give in the form of list and when I am giving in the form of list to be multiple nested arrays okay multiple nested arrays you can also say like oh okay mind writing like this okay cuz I see one like one antics early as the Omegas Krish 292 and taeksoo Oh now instead of insert one I am going to use something insert many okay you just execute and see whether all the records will get updated so pretty much simple yes a hold of the records has got updated and you can see that insert many results if I want to prove it to you again go back to mine MongoDB come fast now if I reload it you can see that fresh fresh fresh one Krish to hot mission has been stowed this is how you do this and guys this is just a basic thing that I've showed you in the later upcoming videos I'll try to create a model whatever output comes from the word particular model I try to store that in the morning I hope you like this particular tutorial please to subscribe the channel if you are not a racist as you're in the next video [Music] you

Original Description

Please join as a member in my channel to get additional benefits like materials in Data Science, live streaming for Members and many more https://www.youtube.com/channel/UCNU_lfiiWBdtULKOw6X0Dig/join Please do subscribe my other channel too https://www.youtube.com/channel/UCjWY5hREA6FFYrthD0rZNIw Connect with me here: Twitter: https://twitter.com/Krishnaik06 Facebook: https://www.facebook.com/krishnaik06 instagram: https://www.instagram.com/krishnaik06
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Krish Naik · Krish Naik · 0 of 60

← Previous Next →
1 Natural Language Processing|Stemming
Natural Language Processing|Stemming
Krish Naik
2 Natural Language Processing|BagofWords
Natural Language Processing|BagofWords
Krish Naik
3 Gaussian distribution or Normal Distribution in statisctics
Gaussian distribution or Normal Distribution in statisctics
Krish Naik
4 Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Natural Language Processing|TF-IDF for Machine Learning| Text Prerocessing
Krish Naik
5 Log Normal Distribution in Statistics
Log Normal Distribution in Statistics
Krish Naik
6 Covariance in Statistics
Covariance in Statistics
Krish Naik
7 Confusion matrix, Precision, Recall| Data Science Interview questions
Confusion matrix, Precision, Recall| Data Science Interview questions
Krish Naik
8 Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Tutorial 44-Balanced vs Imbalanced Dataset and how to handle Imbalanced Dataset
Krish Naik
9 Implementing a Spam classifier in python| Natural Language Processing
Implementing a Spam classifier in python| Natural Language Processing
Krish Naik
10 Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Tutorial 11-Exploratory Data Analysis(EDA) of Titanic dataset
Krish Naik
11 Face Recognition using open CV and VGG 16 Transfer Learning
Face Recognition using open CV and VGG 16 Transfer Learning
Krish Naik
12 Pedestrian Detection using OpenCV from Videos
Pedestrian Detection using OpenCV from Videos
Krish Naik
13 Face and Eye Detection from Videos using HAAR Cascade Classifier
Face and Eye Detection from Videos using HAAR Cascade Classifier
Krish Naik
14 Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Reading, Writing and Displaying images with Opencv| OpenCV Tutorial
Krish Naik
15 OpenCV Installation | OpenCV tutorial
OpenCV Installation | OpenCV tutorial
Krish Naik
16 Face and Eye Detection from Images using HAAR Cascade Classifier
Face and Eye Detection from Images using HAAR Cascade Classifier
Krish Naik
17 Car Detection using HAAR Cascade and Opencv from Videos.
Car Detection using HAAR Cascade and Opencv from Videos.
Krish Naik
18 Using OpenFace for Face recognition in Keras
Using OpenFace for Face recognition in Keras
Krish Naik
19 OpenPose Tutorial with Tensorflow
OpenPose Tutorial with Tensorflow
Krish Naik
20 Multiple Linear Regression using python and sklearn
Multiple Linear Regression using python and sklearn
Krish Naik
21 Dimensional Reduction| Principal Component Analysis
Dimensional Reduction| Principal Component Analysis
Krish Naik
22 Movie Recommender System using Python
Movie Recommender System using Python
Krish Naik
23 TPR,FPR,FNR,TNR, Confusion Matrix
TPR,FPR,FNR,TNR, Confusion Matrix
Krish Naik
24 Precision, Recall and F1-Score
Precision, Recall and F1-Score
Krish Naik
25 Artificial Neural Network for Customer's Exit Prediction from Bank
Artificial Neural Network for Customer's Exit Prediction from Bank
Krish Naik
26 GridSearchCV- Select the best hyperparameter for any Classification Model
GridSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
27 RandomizedSearchCV- Select the best hyperparameter for any Classification Model
RandomizedSearchCV- Select the best hyperparameter for any Classification Model
Krish Naik
28 K Nearest Neighbor classification with Intuition and practical solution
K Nearest Neighbor classification with Intuition and practical solution
Krish Naik
29 K Means Clustering Intuition
K Means Clustering Intuition
Krish Naik
30 Create custom Alexa Skill- Lambda function- Part2
Create custom Alexa Skill- Lambda function- Part2
Krish Naik
31 Hierarchical Clustering intuition
Hierarchical Clustering intuition
Krish Naik
32 Implement Transfer Learning with a generic Code Template
Implement Transfer Learning with a generic Code Template
Krish Naik
33 Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Gender Classifier and Age Estimator using Resnet Convolution Neural Network
Krish Naik
34 Unlock Your Application With Your Face using OpenCV
Unlock Your Application With Your Face using OpenCV
Krish Naik
35 Draw rectangle from webcam and sketch process it on a live feed
Draw rectangle from webcam and sketch process it on a live feed
Krish Naik
36 Complete Life Cycle of a Data Science Project
Complete Life Cycle of a Data Science Project
Krish Naik
37 How we can apply Machine Learning in Finance
How we can apply Machine Learning in Finance
Krish Naik
38 Deep Learning in Medical Science
Deep Learning in Medical Science
Krish Naik
39 How to switch your career to Data Science.
How to switch your career to Data Science.
Krish Naik
40 Linear Regression Mathematical Intuition
Linear Regression Mathematical Intuition
Krish Naik
41 Handle Categorical features using Python
Handle Categorical features using Python
Krish Naik
42 Machine Learning Algorithm- Which one to choose for your Problem?
Machine Learning Algorithm- Which one to choose for your Problem?
Krish Naik
43 DBSCAN Clustering Easily Explained with Implementation
DBSCAN Clustering Easily Explained with Implementation
Krish Naik
44 Curse of Dimensionality Easily explained| Machine Learning
Curse of Dimensionality Easily explained| Machine Learning
Krish Naik
45 Feature Selection Techniques Easily Explained | Machine Learning
Feature Selection Techniques Easily Explained | Machine Learning
Krish Naik
46 Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Tutorial 29-R square and Adjusted R square Clearly Explained| Machine Learning
Krish Naik
47 Cross Validation using sklearn and python | Machine Learning
Cross Validation using sklearn and python | Machine Learning
Krish Naik
48 Handling Missing Data Easily Explained| Machine Learning
Handling Missing Data Easily Explained| Machine Learning
Krish Naik
49 Deploy Machine Learning Model using Flask
Deploy Machine Learning Model using Flask
Krish Naik
50 Deployment of Deep Learning Model using Flask
Deployment of Deep Learning Model using Flask
Krish Naik
51 How to Visualize Multiple Linear Regression in python
How to Visualize Multiple Linear Regression in python
Krish Naik
52 K Nearest Neighbour Easily Explained with Implementation
K Nearest Neighbour Easily Explained with Implementation
Krish Naik
53 Predicting Heart Disease using Machine Learning
Predicting Heart Disease using Machine Learning
Krish Naik
54 Predicting Lungs Disease using Deep Learning
Predicting Lungs Disease using Deep Learning
Krish Naik
55 Stock Sentiment Analysis using News Headlines
Stock Sentiment Analysis using News Headlines
Krish Naik
56 Random Forest(Bootstrap Aggregation) Easily Explained
Random Forest(Bootstrap Aggregation) Easily Explained
Krish Naik
57 Voting Classifier(Hard Voting and Soft Voting Classifier)
Voting Classifier(Hard Voting and Soft Voting Classifier)
Krish Naik
58 Credit Card Fraud Detection using Machine Learning from Kaggle
Credit Card Fraud Detection using Machine Learning from Kaggle
Krish Naik
59 Hyperparameter Optimization for Xgboost
Hyperparameter Optimization for Xgboost
Krish Naik
60 Tutorial 45-Handling imbalanced Dataset  using python- Part 1
Tutorial 45-Handling imbalanced Dataset using python- Part 1
Krish Naik

Related AI Lessons

Up next
I Asked ChatGPT to Apply to 500 Jobs (8 Interviews in 48 Hours)
Sabrina Ramonov 🍄
Watch →