Created
April 11, 2017 00:03
-
-
Save johnrichardrinehart/7451e4d2c657c3f09030b77fa506a5d4 to your computer and use it in GitHub Desktop.
This file contains 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 motor.motor_asyncio | |
import asyncio | |
client = motor.motor_asyncio.AsyncIOMotorClient('localhost', 27017) | |
db = client['testDB'] | |
async def do_insert(user, collection_name): | |
document = {'user': user} | |
result = await db[collection_name].insert_one(document); | |
print('Added user %s' % user) | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(do_insert('john', 'testCollection')) | |
loop.run_until_complete(do_insert('maximo', 'testCollection')) | |
loop.run_until_complete(do_insert('phoenix', 'testCollection')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment