Last active
December 11, 2015 22:58
-
-
Save 5263/4673448 to your computer and use it in GitHub Desktop.
query the calc database
This file contains hidden or 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
#/usr/bin/env python | |
import sqlite3 | |
conn=sqlite3.connect('memento.sqlite') | |
cr=conn.cursor() | |
calcslist=cr.execute("SELECT * FROM `entry`").fetchall() | |
calcsdict=dict((entry[0].lower(),entry) for entry in calcslist) | |
conn.close() | |
if __name__ = '__main__': | |
import sys | |
if len(sys.argv) > 1: | |
for arg in sys.argv[1:]: | |
print calcsdict.get(arg) | |
else: | |
import random | |
print(random.choice(calcslist)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment