You're attempting to extract the row value from a string, which is an object without a row value. In order to accomplish this, you'll also need to build a loop that takes the row number into account.
DATABASE_FILE = "your_database_file.xlsx"
DATABASE_SHEET = "your_database_sheet"
def add_to_database(object_name, value):
workbook = openpyxl.load_workbook(DATABASE_FILE)
worksheet = workbook[DATABASE_SHEET]
object_row_num = None
for row_num, row in enumerate(worksheet.iter_rows(min_row=1, max_row=worksheet.max_row, values_only=True), start=1):
if row == object_name:
object_row_num = row_num
worksheet.cell(row=object_row_num, column=2).value += value
last_row = worksheet.max_row + 1
worksheet.cell(row=last_row, column=1).value = object_name
worksheet.cell(row=last_row, column=2).value = value