Guest User

Untitled

a guest
Nov 18th, 2017
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. import requests
  2. import json
  3. from pymongo import MongoClient
  4.  
  5. url = "[YOUR_RAKAM_API]/event/collect"
  6.  
  7. client = MongoClient()
  8. client = MongoClient('localhost', 27017)
  9. db = client.test_database
  10. posts = db.posts
  11.  
  12. for post in posts.find():
  13. response = requests.post(url, data=json.dumps({"api":{"api_key":"YOUR_WRITE_KEY"},
  14. "collection": "collection_name","properties":{ "_time": "2017-01-01T00:00:01", "_user": "userid", "an_attribute": post.get('an_attribute')}}))
Add Comment
Please, Sign In to add comment