I have written the below Python program to create a MongoDB.
import pymongo
myclient = pymongo.MongoClient('mongodb://localhost:27017/')
mydb = myclient['mydatabase']
dblist = myclient.list_database_names()
if "mydatabase" in dblist:
print("The database exists.")
else :
print("The database does not exists.")
But while I execute the program , I get the result as
The database does not exists.
Why so? Is there something that I am missing ?
I am following the code mentioned in W3Schools Tutorial