Найдено решение: я получаю эту ошибку при выполнении моего кода -> TypeError: недостаточно аргументов для строки формата - PullRequest
0 голосов
/ 15 марта 2020

Не уверен, как решить эту проблему. Когда я использовал отладчик, функция execute не работает.

# this function updates the record chosen by the user
def update_record(vector_to_update):
logging.debug("Executing: update_record")
try:
    with mydb.cursor() as cursor:
        # prepared statement to update a record in the database
        update_query = ('UPDATE myTable SET ref_date = %s, geo = %s, sex = %s, age_group = %s, '
                        'student_response = %s, uom = %s, uom_id = %s, scalar_factor = %s, scalar_id = %s, '
                        'vector = %s, coordinate = %s, value_field = %s, decimals = %s WHERE vector = "%s"')
        # calls on the user_input function in the dataModel file and stores input in "data"
        data = dataModel.user_input()
        # execute the query using the vector_to_update in the query
        cursor.execute(update_query, (data, vector_to_update))
        # commit changes to database
        mydb.commit()
        print('Updating data for vector: {}'.format(vector_to_update))
        cursor.close()

except pymysql.DatabaseError as error:
    # if no connection to database
    print("Update record failed to execute {}".format(error))
    # tells the user the input is invalid and goes back thru the delete_record function
    menu_update_record()
...