""" AUTHOR: Khushal P Soonderji DATE: Thursday, 19th Sept., 2024 OBJECTIVE: To provide a quick way to test out MongoDB. REFERENCES: N/A DOWNLOADS: N/A """ # ***************************************************************************************************************** # ***** **** # *** IMPORT *** # ***** **** # ***************************************************************************************************************** # To make sibling directories accessible for imports: import sys sys.path.append(".") sys.path.append("..") # System-level: import os # Utils: from utils_v2.string import json from utils_v2.date_time import date_time from utils_v2.database.async_mongo_v2 import AsyncMongo # For async activities: import asyncio # Common: from shared import constants # ***************************************************************************************************************** # ***** **** # *** MACROS / ONE-TIME INIT *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** VARIABLES *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** FUNCTIONS *** # ***** **** # ***************************************************************************************************************** # --- Nothing Yet # ***************************************************************************************************************** # ***** **** # *** MAIN PROGRAM *** # ***** **** # ***************************************************************************************************************** if __name__ == "__main__": async def main(): # Create an instance of the database connector: my_db = AsyncMongo( connection_string = constants.MONGO_DATA_CONNECTION_STRING, database_name = constants.MONGO_DATA_DATABASE_NAME, max_connections = 10, debug = True ) await my_db.connect() # Get some data to know if things are working well: matching_data = await my_db.find_many( collection = "logs", filter = {}, sort = {"_id": -1}, limit = 3 ) print("Data:", my_db.to_json_string(matching_data)) asyncio.run(main())