# ---
# jupyter:
#   jupytext:
#     text_representation:
#       extension: .py
#       format_name: light
#       format_version: '1.5'
#       jupytext_version: 1.14.4
#   kernelspec:
#     display_name: Python 3
#     language: python
#     name: python3
# ---

# # Accessing MongoDB
#
# Quick dmp of accessing MongoDB using `pymongo`.

#Whar version of mongo are we running?
# !mongod --version

# ## Accessing the Database using the `pymongo` client
#
# The `pymongo` client provides a convernient wrapper for talking to the mongo database.

from pymongo import MongoClient

#If connecting to the default port, we can omit the port number parameter
c = MongoClient()

# List the databases
c.list_database_names()

# +
#Create a test database...
db = c.test_database

#And a test collectioninside that database...
coll = db.stuff
# -

# List the databases
c.list_database_names()

#Insert a couple of items
item = {"field": "value","field3": "other"}
coll.insert_one(item)

#See if we can find something in the collection
coll.find_one()



StarcoderdataJupyterScriptsDedupFiltered