def update_quantity_command(self): try: tup = recent_selection['selected'] item_name = self.inventory_treeview.item(tup[0])['text'] answer = simpledialog.askinteger( 'Input', f'How many {item_name} do you have?', parent=self.root, minvalue=1, maxvalue=1000) self.inventory_treeview.set(tup, 'quantity', answer) sql.execute_sql(self.conn, sql.update_quantity(), answer, item_name, user_info['inv']) except TclError: error_box.no_inventory_item_selected()
async def submit_command(message, paste_url, recipient): errors = "No Errors" sqlLabelInsert = (''' INSERT IGNORE `labels_submitted`(`Label`) VALUES (%s) ''') sqlPlayersInsert = (''' INSERT IGNORE `players_submitted`(`Players`) VALUES (%s) ''') sqlLabelID = (''' SELECT ID FROM `labels_submitted` WHERE Label = %s ''') sqlPlayerID = (''' SELECT ID FROM `players_submitted` WHERE Players = %s ''') sqlInsertPlayerLabel = (''' INSERT IGNORE `playerlabels_submitted`(`Player_ID`, `Label_ID`) VALUES (%s, %s) ''') try: paste_soup = sql.get_paste_data(paste_url) List = sql.get_paste_names(paste_soup) labelCheck = sql.get_paste_label(paste_soup) sql.execute_sql(sqlLabelInsert, insert=True, param=[labelCheck]) sql.InsertPlayers(sqlPlayersInsert, List) dfLabelID = pd.DataFrame( sql.execute_sql(sqlLabelID, insert=False, param=[labelCheck])) playerID = sql.PlayerID(sqlPlayerID, List) sql.InsertPlayerLabel(sqlInsertPlayerLabel, playerID, dfLabelID) except Exception as e: errors = str(e) msg = "```diff" + "\n" \ + "Paste Information Submitted" + "\n" \ + "_____________________" + "\n" \ + "+ Link: " + str(paste_url) + "\n" \ + "+ Errors: " + str(errors) + "\n" \ + "```" await recipient.send(msg)
def in_inventory(conn, inv_id, item, add_subtract=None): # [('Club', '1'), ('Dagger', 1)] items_in_inv_list = sql.execute_fetchall_sql( conn, sql.query_items_in_inventory(), inv_id) for tup in items_in_inv_list: if item in tup: if add_subtract == '+': int_quantity = int(tup[1]) int_quantity += 1 sql.execute_sql(conn, sql.update_quantity(), int_quantity, tup[0], inv_id) return True elif add_subtract == '-': int_quantity = int(tup[1]) if int_quantity > 1: int_quantity -= 1 sql.execute_sql(conn, sql.update_quantity(), int_quantity, tup[0], inv_id) return True return False
def delete_character_inventories(conn, char_id): sql.execute_sql(conn, sql.delete_all('inventories', 'character_id'), char_id)
def delete_all_character_items(conn, char_id): sql.execute_sql(conn, sql.delete_all('items', 'character_id'), char_id)
def delete_item(conn, item, inv_id): sql.execute_sql(conn, sql.delete_item(), item, inv_id)
def add_store_item(conn, some_sql, item_info): sql.execute_sql(conn, some_sql, item_info['item'], item_info['api'], item_info['currency'], item_info['store'])
def add_item_row(conn, some_sql, item_info): sql.execute_sql(conn, some_sql, item_info['acc_id'], item_info['char_id'], item_info['inv_id'], item_info['item'], item_info['api'], item_info['value'], item_info['quantity'])
def add_character_row(conn, some_sql, char_info): sql.execute_sql(conn, some_sql, char_info['acc_id'], char_info['name'], char_info['currency'])
def add_inventory_row(conn, some_sql, inv_info): sql.execute_sql(conn, some_sql, inv_info['acc_id'], inv_info['char_id'], inv_info['name'])
def add_account_row(conn, some_sql, acc_info): sql.execute_sql(conn, some_sql, acc_info['username'], acc_info['password'])
def delete_character(conn, char_id): delete_all_character_items(conn, char_id) delete_character_inventories(conn, char_id) sql.execute_sql(conn, sql.delete_all('characters', 'id'), char_id)
def update_currency_db(self, conn): sql.execute_sql(conn, sql.update_currency(), self.currency, self.id)
def create_schema(conn): sql.execute_sql(conn, sql.create_accounts_table()) sql.execute_sql(conn, sql.create_characters_table()) sql.execute_sql(conn, sql.create_inventories_table()) sql.execute_sql(conn, sql.create_items_table())
def test_execute_sql(self): with mock.patch('sql.sqlite3') as mocksql: conn = mocksql.connect() call = """some sql""" sql.execute_sql(conn, call) mocksql.connect().execute.assert_called_with(call, ())