예제 #1
0
def newstat(date, stat, number):
    dbcxn = lifestream.getDatabaseConnection()
    cursor = lifestream.cursor(dbcxn)

    s_sql = u"replace into lifestream_stats (`date`, `statistic`, `number`) values (%s, %s, %s);"
    cursor.execute(s_sql, (date, stat, number))

    # print cursor._last_executed

    dbcxn.commit()
    dbcxn.close()
    return True
예제 #2
0
# Local
import lifestream
import lifestreamutils


if (len(sys.argv) < 2):
    print "Usage: %s statistic filename" % (sys.argv[0])
    sys.exit(5)

STATISTIC = sys.argv[1]
FILENAME = sys.argv[2]

DEBUG = False

dbcxn = lifestream.getDatabaseConnection()
cursor = lifestream.cursor(dbcxn)

inbox = mailbox.mbox(FILENAME)

dates = {}
datekeys = []

length = len(inbox)
count = 0.0

if DEBUG:
    print FILENAME
    print "0%"

for key in inbox.iterkeys():