Reputation: 21
I'm pretty new to mongodb and i'm tryin to figure out how can I connect to my database with python externally.
import pymongo
myclient = pymongo.MongoClient("mongodb://localhost:27017/")
mydb = myclient["mydatabase"]
mycol = mydb["customers"]
in this example, you connect to your mongodb using a localhost, but I cant figure out how to connect my DB by remote and not locally. (More like, how do I get even a URI to put in there, im digging in mongodb website but im lost)
Thanks in advance!
Upvotes: 0
Views: 1931
Reputation: 775
From the documentation:, connection string:
mongodb://[username:password@]host1[:port1][,...hostN[:portN]][/[defaultauthdb][?options]]
What you need at least:
localhost
, you will need an ip
or address
to connect to a remote database)Upvotes: 2