Skip to content

Instantly share code, notes, and snippets.

@avelino
Created December 23, 2012 12:59
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save avelino/4363275 to your computer and use it in GitHub Desktop.
Save avelino/4363275 to your computer and use it in GitHub Desktop.
Inset 1000000 records in MongoDB via Python
#!/usr/bin/env python
# -*- coding: utf-8 -*-
from pymongo import MongoClient
connection = MongoClient()
db = connection.test
persons = db.persons
for i in range(0, 1000000):
person = persons.insert({'name': 'Thiago Avelino %d' % i,
'age': 18+i,
'language': ['python'],})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment