Skip to content

Commit

Permalink
Updates to fetch script
Browse files Browse the repository at this point in the history
  • Loading branch information
johc committed Mar 27, 2024
1 parent 5e6b241 commit 85c7cde
Showing 1 changed file with 17 additions and 7 deletions.
24 changes: 17 additions & 7 deletions fetch_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,22 @@

# Connect to MongoDB
client = MongoClient(os.environ['MONGODB_URI'])
db = client.your_database_name # Replace with your database name
db = client.FMD # Assuming 'FMD' is your database name

# Fetch data from a collection
collection = db.your_collection_name # Replace with your collection name
data = list(collection.find({}))
# Fetch data from FMD.Endpoints collection
endpoints_data = list(db.Endpoints.find({}))

# Save to a JSON file
with open('data.json', 'w') as file:
json.dump(data, file)
# Save Endpoints data to a JSON file
endpoints_file_path = 'fmd-telemetry/fmd-telemetry/src/assets/Endpoints.json'
os.makedirs(os.path.dirname(endpoints_file_path), exist_ok=True)
with open(endpoints_file_path, 'w') as file:
json.dump(endpoints_data, file)

# Fetch data from FMD.UserSession collection
user_session_data = list(db.UserSession.find({}))

# Save UserSession data to a JSON file
user_session_file_path = 'fmd-telemetry/fmd-telemetry/src/assets/UserSession.json'
os.makedirs(os.path.dirname(user_session_file_path), exist_ok=True)
with open(user_session_file_path, 'w') as file:
json.dump(user_session_data, file)

0 comments on commit 85c7cde

Please sign in to comment.