Skip to content

Instantly share code, notes, and snippets.

@5263
Last active December 11, 2015 22:58
Show Gist options
  • Save 5263/4673448 to your computer and use it in GitHub Desktop.
Save 5263/4673448 to your computer and use it in GitHub Desktop.
query the calc database
#/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