Created
July 19, 2022 11:44
-
-
Save dubeyji10/ae074b6396267e327de0281271d9644f to your computer and use it in GitHub Desktop.
Connection to local mongodb instance for test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from pprint import pprint | |
from pymongo import MongoClient | |
#mongodb://127.0.0.1:27017/ | |
client = MongoClient(host="localhost", port=27017) | |
print("1.connected to mongodb") | |
db = client.landTest | |
print("2.db : ",db) | |
# print("") | |
collection = db.landTest | |
print("\n\n3.collection:",collection) | |
client.close() | |
print("4.documents : \n") | |
for doc in collection.find(): | |
pprint(doc) | |
print('-----------------') | |
print("\n\n--connection closed--") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment