Python 3 PyMongo Library Script to Connect Cloud Atlas NoSQL MongoDB Database and Insert Data Full Example For Beginners

You are currently viewing Python 3 PyMongo Library Script to Connect Cloud Atlas NoSQL MongoDB Database and Insert Data Full Example For Beginners

 

Welcome folks today in this blog post we will be connecting to mongodb atlas database inside our python script using pymongo library. All the full source code of the application is given below.

 

 

Get Started

 

 

In order to get started you need to install the following library using the pip command as shown below

 

pip install pymongo

 

pip install dnspython

 

After installing this library you need to make an app.py file and copy paste the following code

 

app.py

 

 

And now inside the above python script you need to replace the database name and server name and also the collection or table name that you will get from mongodb server as shown below

 

 

 

Now if you execute the above python script by typing the below command as shown below

 

python app.py

 

 

 

So you can see one record has been added to the mongodb database because of the python script

 

Leave a Reply