<jupyter_start><jupyter_text>Import the libraries<jupyter_code>import pymongo
from pymongo import MongoClient<jupyter_output><empty_output><jupyter_text>Establish connection<jupyter_code>connection = MongoClient('localhost', 27017)
db = connection.Employee #dtabase name<jupyter_output><empty_output><jupyter_text>Print all collection name/table name<jupyter_code>db.list_collection_names(include_system_collections=False)<jupyter_output><empty_output><jupyter_text>Select any one collection/table to show data and Print each individual record<jupyter_code>data = db.empdata #table nme / collection name
EmployeeList = data.find()
for item in EmployeeList:
    print(item)<jupyter_output>{'_id': ObjectId('60ec30db293b5702d9473b0f'), 'Name': 'Harihar', 'Age': 12.0}
{'_id': ObjectId('60ec3177293b5702d9473b10'), 'Name': 'Harihar', 'Age': 32.0}
{'_id': ObjectId('60ec317d293b5702d9473b11'), 'Name': 'Harihar', 'Age': 62.0}
{'_id': ObjectId('60ec3186293b5702d9473b12'), 'Name': 'Harihdd', 'Age': 62.0}<jupyter_text>Create a dataframe to give structure to the NoSQL data<jupyter_code>import pandas as pd
df = pd.DataFrame(list(data.find()))
df<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13247863247863248, 'fraction_numerical': 0.07606837606837606, 'mean_word_length': 10.368932038834952, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '5', 'dir': 'jupyter-structured-clean-dedup', 'id': '198458', 'license': 'MIT', 'n_tokens_mistral': 490, 'n_tokens_neox': 428, 'n_words': 80, 'path': 'Database Connection/PyMongoDB/Extract_data_from_MongoDB_using_Python.ipynb', 'repo_name': 'jrderek/Data-science-master-resources', 'size': '1170'}