title: how to parameterize a mongodb query in python
body: <p>I have a list with some mongodb queries in python, but I can't get data from some complicated queries that works in mongodb.</p>
  <pre><code>    sql = [        
          [
            {&quot;$match&quot;: {
                &quot;status&quot;: {&quot;$in&quot; : [&quot;BUILDING&quot;]}
                }
            }
            ,{&quot;$group&quot;: {
                &quot;_id&quot;: '$status', &quot;count&quot;: {&quot;$count&quot;: {}}
                 }
              }
           ],        
       ]
  
       collection = client[&quot;send&quot;][&quot;sendEntity&quot;]
       mydoc = list(collection.find(myquery))
  </code></pre>
  <p>The error is as follows:</p>
  <pre><code>&lt;class 'TypeError'&gt;
  </code></pre>
  <p>traceback</p>
  <pre><code>    Traceback (most recent call last):
        File &quot;getSql.py&quot;, line 14, in &lt;module&gt;
          mydoc = list(collection.find(myquery))
        File &quot;/home/r/Desktop/table_csv/virtual/lib/python3.8/site-packages/pymongo/collection.py&quot;, line 1643, in find
          return Cursor(self, *args, **kwargs)
        File &quot;/home/r/Desktop/table_csv/virtual/lib/python3.8/site-packages/pymongo/cursor.py&quot;, line 215, in __init__
          validate_is_mapping(&quot;filter&quot;, spec)
        File &quot;/home/r/Desktop/table_csv/virtual/lib/python3.8/site-packages/pymongo/common.py&quot;, line 511, in validate_is_mapping
          raise TypeError(
      TypeError: filter must be an instance of dict, bson.son.SON, or any other type that inherits from collections.Mapping
  </code></pre>