Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

MongoWatch provides an easy way to measure mongo database access counts, and timeing, between certain points in a program.

First let’s access the database and get a db object

>>> import pymongo
>>> conn = pymongo.Connection('localhost', 27017, tz_aware=False)
>>> db = conn[DBNAME]

Our example collections relate to street life, traffic, and crowds

>>> traffic = db.cars
>>> crowd = db.people

Let’s create a vehicle to represent something already in a collection

>>> obj = traffic.insert({'car': 'red'})

Now create a watcher track mongo profile entries created by actions on the selected database

>>> from mongowatch.mongo import watcher
>>> wa = watcher.Watcher(conn,[DBNAME])

Now, let’s add one item to traffic:

>>> obj = traffic.insert({'truck':'blue'})

And we’ll add two people to the crowd:

>>> obj = crowd.insert({'name':'billy'})
>>> obj = crowd.insert({'name':'jane'})

Which resulted in the following actions being recorded in the watcher.

>>> wa.dump()
total ops:
  inserts: 3
summary:
  database: mongowatch_test
     cars
       inserts: 1
     people
       inserts: 2
details:
  ns mongowatch_test.cars
  op insert
  ts 2011-12-13 08:27:05.496000
  millis ...
<BLANKLINE>
  ns mongowatch_test.people
  op insert
  ts 2011-12-13 08:27:05.498000
  millis ...
<BLANKLINE>
  ns mongowatch_test.people
  op insert
  ts 2011-12-13 08:27:05.498000
  millis ...
<BLANKLINE>

Let’s reset the counters

>>> wa.reset()

So now do some more work

>>> crowd.remove({})
>>> traffic.remove({})
>>> obj = crowd.insert({'name':'bonzo'})
This time we stop the watcher explicity
>>> wa.stop()
>>> wa.dump()
total ops:
  inserts: 1
  removes: 2
summary:
  database: mongowatch_test
     cars
       removes: 1
     people
       inserts: 1
       removes: 1
details:
  ns mongowatch_test.people
  op remove
  query {}
  ts 2011-12-13 07:47:51.921000
  millis 0
<BLANKLINE>
  ns mongowatch_test.cars
  op remove
  query {}
  ts 2011-12-13 07:47:51.921000
  millis 0
<BLANKLINE>
  ns mongowatch_test.people
  op insert
  ts 2011-12-13 07:47:51.921000
  millis 0
<BLANKLINE>
>>> conn.disconnect()

Metadata

Release files for mongowatch 0.1.2dev

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for mongowatch 0.1.2dev
File Size Uploaded Provenance Actions
mongowatch-0.1.2dev.tar.gz 4.6 kB Without provenance Details for mongowatch-0.1.2dev.tar.gz

Release files / mongowatch-0.1.2dev.tar.gz

Download URL mongowatch-0.1.2dev.tar.gz
Size 4.6 kB
Tags Source
SHA-256 checksum
How to use checksums
5bdafd04cf9b618910ce255c89d1f71547bcb2c56fe88979e864c7164c179000
BLAKE2b-256 checksum
How to use checksums
ef1741c2a65b4b8e61e813408430b6eb1c943211835012a934959721c2380cbb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for mongowatch 0.1.2dev

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page