Skip to content
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
30 lines (22 sloc) 685 Bytes
import config
import logging
import csv
from redis import StrictRedis
# We do not want to use __name__ here because __name__ is "__main__"
log = logging.getLogger("presidents.importer")
reader = csv.reader(open("./presidents.csv"))
header =
client = StrictRedis()
for i, row in enumerate(reader):
key = "president:%s" % (row[0], )
doc = dict(zip(header, row))
# simulate a disconnect every 3 operations
if i % 3 == 0:
# simulate a failure
if row[0] == "37":
raise Exception("Crook.")
client.set(key, doc)
log.exception("Dang it.")
You can’t perform that action at this time.