Spaces:
Sleeping
Sleeping
from db_utils import DatabaseUtils | |
def main(): | |
db_utils = DatabaseUtils() | |
try: | |
print("\nDatabases and Collections in your Atlas cluster:\n") | |
# Get all databases | |
databases = db_utils.get_databases() | |
# For each database, show collections and counts | |
for db_name in databases: | |
print(f"Database: {db_name}") | |
collections = db_utils.get_collections(db_name) | |
for coll_name in collections: | |
info = db_utils.get_collection_info(db_name, coll_name) | |
print(f" βββ Collection: {coll_name} ({info['count']} documents)") | |
print() | |
except Exception as e: | |
print(f"Error: {str(e)}") | |
finally: | |
db_utils.close() | |
if __name__ == "__main__": | |
main() | |