How can I use the mongolab add-on to Heroku from python?

前端 未结 5 1371
旧时难觅i
旧时难觅i 2021-01-14 13:43

The documentation only talks about how to do it from ruby.

5条回答
  •  误落风尘
    2021-01-14 14:42

    PyMongo now provides a get_default_database() method that makes this entire exercise trivial:

    from pymongo import MongoClient
    
    client = MongoClient(os.environ['MONGOLAB_URI'])
    db = client.get_default_database()
    

提交回复
热议问题