Skip to content

Instantly share code, notes, and snippets.

@mehdimehdi
Created March 18, 2012 21:46
Show Gist options
  • Save mehdimehdi/2082090 to your computer and use it in GitHub Desktop.
Save mehdimehdi/2082090 to your computer and use it in GitHub Desktop.
appending data to table
from django.db import connections, transaction
cursor = connections['noudata'].cursor()
# Data modifying operation - commit required
cursor.execute("insert into activity (user_id,name,remote_addr,referrer,hostname,points,date_created,_id,publisher_id) select user_id,name,remote_addr,referrer,hostname,points,date_created,_id,publisher_id from bson('s3://punchtab-mongolab-backups/%s');" % file_name)
transaction.commit_unless_managed() #I also tried without the commit
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment