title: Python + MongoDB, how to dynamically choose DB Collection
body: <p>How can I dynamically point to a particular collection name in MongoDB with Python?  </p>
  
  <p>I receive data from any 1 of a few dozen sensors in my network, and I want to store the raw data into a db collection named for the sensor. </p>
  
  <pre class="lang-py prettyprint-override"><code># Server Parameters
  host = '1.2.3.4'
  port = 27017
  client = MongoClient(host, port)
  db = client.myDB                # use database myDB
  
  # receive data from sensors
  # {"sensorName":"...", "x":"...", "y":"...", "z":"...", "time":"..."}
  
  db.SensorA.insert_one({...})    # record raw data in the collection for SensorA
  db.SensorB.insert_one({...})
  db.SensorC.insert_one({...})
  </code></pre>
  
  <p>Instead of explicitly writing <code>db.SensorName.insert_one({...})</code>, I'd like to somehow reference the given sensor/collection name.</p>
  
  <p>Thanks</p>