Skip to content

Instantly share code, notes, and snippets.

@idank
Created June 19, 2013 08:43
Show Gist options
  • Save idank/5812727 to your computer and use it in GitHub Desktop.
Save idank/5812727 to your computer and use it in GitHub Desktop.
src = pymongo.Connection()
dst = pymongo.Connection(<mongos addr>)
srcdb = src[db]
dstdb = dst[db]
srccoll = srcdb[collection]
dstcoll = dstdb[collection]
logging.basicConfig(format='%(asctime)s %(message)s', level=logging.INFO)
i = 0
for i, d in enumerate(srccoll.find()):
if i % 10000 == 0:
logging.info('did %d', i)
dstcoll.save(d)
logging.info('did a total of %d', i)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment