Pymongo usage with vpn

Question:

I am kinda new to pymongo. Is there any possible way to connect to mongodb with the usage of the VPN, if I have server address, login and password of the vpn server?

I have googled, but didn’t find anything useful.

Asked By: Mikhail Zhokhov

||

Answers:

Sure, here you could do it with the pymongo library

import pymongo
from pymongo import import MongoClient

client = MongoClient('mongodb://MikhailZhokhov:password@mongo_server_ip:27017/')
db = client['yourdatabase']
collection = db['mycollection']
result = collection.find_one({'name': 'Mikhail Zhokhov'})

client.close()

Modify the above code accordigly, notice that your VPN need to be properly setup before running this script

Answered By: Saxtheowl
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.