PyMongo has already been initialized for you and is ready to be consumed at app.data.driver.
app.data.driver
Try with the following:
mongo = app.data.driverprint mongo.db.activity.count()