Ejemplo n.º 1
0
def get_posts():
    conn = get_connection('postmash')
    sql = "SELECT postid, text from posts"
    curs = conn.cursor(cursor_factory=DictCursor)
    curs.execute(sql)
    r = redis.StrictRedis(host='localhost', port=6379, db=0)
    for row in curs.fetchall():
	print row['postid']
	r.set(row['postid'],row['text'])
Ejemplo n.º 2
0
def insert_mash(data):
    conn = get_connection('postmash')
    sql = "INSERT INTO mashes(leftid, rightid,winner,timestamp,remote_addr) VALUES (%s, %s, %s, %s, %s)"
    conn.cursor().execute(sql, (data['leftid'], data['rightid'], data['winner'], data['timestamp'], data['remote_addr']))
    conn.commit()