Hi I have a database name:Tmobile and it has a collection with two files Mynew and 30dc..
See image
Now i am trying to loop through the files and print any element /file from it.
Below is my code:
import pandas as pd
import json
from pandas.io.json import json_normalize
from unittest.mock import inplace
from pymongo import MongoClient
from idlelib.rpc import response_queue
from pandas import DataFrame
connection = MongoClient('localhost', 27017)
db=connection.Tmobile
collection=db.Collections
#print(collection)
for collection1 in collection.find():
print(collection1)
But when i try this i get the below error:
Traceback (most recent call last):
File "C:\Users\esrilka\eclipse-workspace\My First PyDev Project\dbsample.py", line 13, in <module>
['30dc6d110c7a0d3d371177ac0a3624bc_1', 'Mynew']
for collection in collection.find():
AttributeError: 'list' object has no attribute 'find'