Articles in this section
Category / Section

Fetch Specified Fields from MongoDb using Bold ETL


This article provides guidance on retrieving specific data fields from a MongoDB database using Bold ETL. This process can be accomplished by executing a Python script.


PyMongo is required. In upcoming releases of Bold Reports, it will be included as default.

Environment Commands
Windows C:\BoldServices\Python39\Scripts\pip.exe install pymongo
Linux pip install pymongo

Here is the sample Python code for fetching selected fields from MongoDB.

import pandas as pd
import pymongo

clientcon = pymongo.MongoClient("mongodb://user:password@host:port")

# Select the database and collection.
databasename = clientcon["yourdatabasename"]
collectionname = databasename["yourcollectionname"]

# Define the required columns. 
fields_to_include = {"yourcolumn1": 1, "yourcolumn12": 1}

documents = collectionname.find({}, fields_to_include)

data = list(documents)
for doc in data:
       doc['_id'] = str(doc['_id'])

df = pd.DataFrame(data), table_name="yourtablename")	
  • mongodb://user:password@host:port - Replace your connection string.
  • yourdatabasename - Replace your Database name.
  • yourcollectionname - Replace your Collection name.
  • yourcolumn1,yourcolumn12 - Replace your column name.
  • yourtablename - Replace yourtablename with the desired table name in your destination database.

Please follow the instructions to run the Python script within the Bold ETL platform.
Python DataFrame into Bold Reports.

Was this article useful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied