Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
import sys
import time
import csv
import sqlite3
from google.appengine.datastore import entity_pb
from google.appengine.api import datastore
ct = 0
csvwriter = csv.writer(open('chat.csv', 'w'))
conn = sqlite3.connect("../messages.db", isolation_level=None)
cursor = conn.cursor()
cursor.execute('select id, value from result')
for unused_entity_id, entity in cursor:
entity_proto = entity_pb.EntityProto(contents=entity)
f = datastore.Entity._FromPb(entity_proto)
csvwriter.writerow([f.key().id(), time.mktime(f['created_at'].timetuple()), \
f['message'].encode('utf-8'), f['sender'].id(), f['recipient'].id()])
ct += 1
if ct % 20000 == 0:
print "Ct is %s" % ct
print "done"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.