checking MongoDB IP address is working while MongoDB Compass did't find it

129 Views Asked by At

If I have an MongoDB IP address how can I check is valid, before I do the pymongo connection

here is the pic I know the current IP address is working: https://postimg.cc/4H3WQrRx (picture, the 196.168.xxx.xxx can be open by NoSQLBooster and that IPaddress do store lots of collections/tables ex: "admin", "cloud_db", "eform_detail" etc)

I know my IP address 196.168.xxx.xxx works fine,but

I check it on MongoDB Compass, is not working with error getaddrinfo ENOTFOUND mongodb https://postimg.cc/21m3VmQv (picture on MongoDB)

maybe because I didn't provide correct IP address that I use pymongo raised error

so I want to make sure if I put my mongodb://196.168.xxx.xxx can works fine when I run below code:

import pymongo

client = pymongo.MongoClient("mongodb://196.168.xxx.xxx:27017/")

mydb_Name="cloud_db"

mydb = client[mydb_Name]

print("now exsisting DB are:  ",client.list_database_names())
 
dblist = client.list_database_names()
if mydb_Name in dblist:
  print("Your DB: {0}exsist!!!!".format(mydb_Name))

#the "cloud_db" already exsist in picture I showed, 
# so should list up all DB the ip address has

the NoSQLBooster picture, I connect successfully just by the same IP address196.168.xxx.xxx https://ibb.co/MfTJXk0

I don't readlly think NoSQLBooster has "Connection Editor" but the pic shows the connection

0

There are 0 best solutions below