Skip to content

Instantly share code, notes, and snippets.

@buremba
Created November 16, 2017 08:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buremba/5962855ff1cd11482b8d951631f09a8b to your computer and use it in GitHub Desktop.
Save buremba/5962855ff1cd11482b8d951631f09a8b to your computer and use it in GitHub Desktop.
import requests
import json
from pymongo import MongoClient
url = "[YOUR_RAKAM_API]/event/collect"
client = MongoClient()
client = MongoClient('localhost', 27017)
db = client.test_database
posts = db.posts
for post in posts.find():
response = requests.post(url, data=json.dumps({"api":{"api_key":"YOUR_WRITE_KEY"},
"collection": "collection_name","properties":{ "_time": "2017-01-01T00:00:01", "_user": "userid", "an_attribute": post.get('an_attribute')}}))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment