A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://www.mongodb.com/docs/languages/python/pymongo-driver/current/monitoring-and-logging/ below:

Logging and Monitoring - PyMongo Driver v4.13

On this page, you can see copyable code examples that show common methods you can use to monitor and log events with PyMongo.

Tip

To learn more about any of the methods shown on this page, see the link provided in each section.

To use an example from this page, copy the code example into the sample application or your own application. Be sure to replace all placeholders in the code examples, such as <connection string URI>, with the relevant values for your MongoDB deployment.

You can use the following sample application to test the code examples on this page. To use the sample application, perform the following steps:

  1. Ensure you have PyMongo installed.

  2. Copy the following code and paste it into a new .py file.

  3. Copy a code example from this page and paste it on the specified lines in the file.

1import pymongo2from pymongo import MongoClient34try:5    uri = "<connection string URI>"6    client = MongoClient(uri)78    database = client["<database name>"]9    collection = database["<collection name>"]1011    1213    1415    client.close()1617except Exception as e:18    raise Exception(19        "The following error occurred: ", e)
with collection.watch() as stream:    for change in stream:        print(change)

To learn more about the watch() method, see the Monitor Data with Change Streams guide.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4