Skip to content
This repository was archived by the owner on Nov 3, 2025. It is now read-only.
This repository was archived by the owner on Nov 3, 2025. It is now read-only.

'module' object has no attribute 'Connection' in MongoDBHandler #3

@DeepthiGaddam

Description

@DeepthiGaddam

When I run the code I get the above error. It is because, pymongo doesn't have Connection attribute. This will be fixed if we replace it with MongoClient as shown below
class MongoDBHandler(RequireJSONFormatter):

def __init__(self, host="localhost", db="logs", port=27017,
         collection="logs"):
     logging.Handler.__init__(self)
     self.connection = pymongo.Connection(host, port)

has to be changed to
self.connection = pymongo.MongoClient(host, port)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions