Example #1
0
    exit / e:    exit
"""


if __name__ == "__main__":
    engine = sa.create_engine(DATABASE_URL)
    session = sessionmaker(autoflush=True)
    session.configure(bind=engine)
    sess = session()
    if sys.argv[-1] != "add_question.py" and os.path.isfile(sys.argv[-1]):
        with open(sys.argv[-1]) as questions:
            for q in questions.read().split("\n"):
                q = unicode(q)
                if not sess.query(Question).filter(Question.text == q).all():
                    Question.new(q, sess)
                    print "Added ", q
                else:
                    print "Already in DB:", q
        if raw_input("Are you sure you want to commit? (Y/N)\n>").lower() in ["y", "yes"]:
            sess.commit()
            print "Commited"
        else:
            sess.rollback()
            print "Did not commit"
    else:
        for q in Question.all(sess):
            print q.id, ":", q.text
        while True:
            inp = raw_input("Enter Command:\n>").lower()
            if inp in ["new", "n"]: