How to connect mongoDB with python?
<p><em>I'm calling function with argument value database name. When I print argument other function it's working properly but when i'm connecting this argument value with database it's not giving any output</em></p>

<p><strong>My code is Here.</strong></p>

<pre><code>def myFunction(mydb):
    from pymongo import MongoClient
    print(mydb)
    client = MongoClient('localhost:27017')
    db = client.mydb
    data = db.collection.find().count()
    return data

mydb = 'my_databaseName'
myFunction(mydb);
</code></pre>

<p><em>when I work with the above code it's returning:</em>  </p>

<pre><code>Oputput:0
</code></pre>

<p><em>But when I'm working with this code it's working properly</em></p>

<pre><code> def myFunction(mydb):
        from pymongo import MongoClient
        print(mydb)
        client = MongoClient('localhost:27017')
        db = client.my_databaseName #its static database name
        data = db.collection.find().count()
        return data
</code></pre>

<p><em>So how can I solve this problem?</em> </p>