public
Created

Inset 1000000 records in MongoDB via Python

  • Download Gist
mongodb.py
Python
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
#!/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'],})

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.