Skip to content

Instantly share code, notes, and snippets.

@jplsightm
Created August 4, 2019 18:54
Show Gist options
  • Save jplsightm/439880572d3c3df6985c5f0ab4117024 to your computer and use it in GitHub Desktop.
Save jplsightm/439880572d3c3df6985c5f0ab4117024 to your computer and use it in GitHub Desktop.
def mongo_objs(conn_str, database, tests=[lambda x: x.document_count({})]):
client = pymongo.MongoClient(conn_str)
db = client[database]
sslog = db.sslog
cycle = db.cycle
sslog_results = {}
cycle_results = {}
for test in tests:
try:
sslog_results[test.__name__] = test(sslog)
except TypeError as e:
sslog_results[test.__name__] = e
try:
cycle_results[test.__name__] = test(cycle)
except TypeError as e:
cycle_results[test.__name__] = e
return client, db, sslog, cycle, sslog_results, cycle_results
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment