Created
November 16, 2017 08:56
-
-
Save buremba/5962855ff1cd11482b8d951631f09a8b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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