예제 #1
0
def check_all_stock(conn):
    cursor = conn.execute("select * from Ingredient")
    data = cursor.fetchall()
    for entry in data:
        if entry[3] is None:
            print("stock not set for {}").format(entry[1])
            stocked = raw_input("enter 'S' or 'U' if stocked or unstocked: ").upper()
            if stocked== 'S':
                stocked = 1
            elif stocked== 'U':
                stocked = 0
            else:
                stocked = None
            sqls.set_stock(conn, entry[0], stocked)
예제 #2
0
파일: cocktail.py 프로젝트: DeMcA/cocktail
        if arguments['--only-stocked']:
            # This is hideous. I need a better way of managing my sql queries
            sqls.all_joins = sqls.all_joins+" where "+sqls.exist_join[:-4]
        sqls.print_query(cursor, sqls.all_joins)
    elif arguments['--ingredient']:
        # get a list of ingredient strings
        ingredients = arguments['--ingredient'].split(",")
        sqls.print_query(cursor, sqls.get_cocktails_with_ingredients(
                            ingredients, restrict=arguments['--only-stocked']))
    elif arguments['--drink']:
        drink = arguments['--drink']
        sqls.print_query(cursor, sqls.get_cocktail(
                            drink, restrict=arguments['--only-stocked']))
    if arguments['--stock']:
        for i in arguments['--stock']:
            cursor = conn.execute("select id from Ingredient where name=?",
                                  (i,))
            entry = cursor.fetchone()[0]
            sqls.set_stock(conn, entry, 1)
    if arguments['--unstock']:
        for i in arguments['--unstock']:
            cursor = conn.execute("select id from Ingredient where name=?",
                                  (i,))
            entry = cursor.fetchone()[0]
            sqls.set_stock(conn, entry, 0)
    try:
        database.close()
        conn.close()
    except AttributeError:
        pass