Created
December 4, 2018 04:02
-
-
Save bowbowbow/54120a331ae91ceeb4e1344d0c16bd72 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import pymongo | |
_connection = None | |
def get_db(): | |
global _connection | |
if not _connection: | |
_connection = pymongo.MongoClient('mongodb://127.0.0.1') | |
return _connection['dbname'] | |
if __name__ == '__main__': | |
db = get_db() | |
docs = db['collection_name'].find({}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment