Skip to content

Instantly share code, notes, and snippets.

@bcoe
Created January 8, 2011 23:15
Show Gist options
  • Save bcoe/771237 to your computer and use it in GitHub Desktop.
Save bcoe/771237 to your computer and use it in GitHub Desktop.
Performing a batch insertion using mongate.
from mongate.connection import Connection
connection = Connection(
'example.com',
27080,
https=True,
auth=True,
username='auth_username',
password='auth_password'
)
connection.connect_to_mongo('localhost', 27017)
db = connection.database_name
collection = db.collection_name
batch = Batch(collection, connection)
batch.add_insert({
'batch_insert_1': 3,
'bar': 2
})
batch.add_insert({
'batch_insert_2': 'banana',
'banana': 'apple'
})
batch.add_insert({
'batch_insert_3': 29,
'bar': 2
})
batch.execute()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment