3

when I execute the following code using python programming language and MySQL database

cursor.execute("select max(propernoun_SRNO) from tblauto_tagged")
starting_index = cursor.fetchone()
ending_index = starting_index +len(s)

I get following error:

Traceback (most recent call last):
File "<pyshell#0>", line 1, in <module>
batch(1,1)
File "C:\Users\vchauhan\Dropbox\Code\proper_noun_function_batch_file_mysql_sept_12.py", line 97, in batch
ending_index = starting_index +len(s)
TypeError: unsupported operand type(s) for +: 'pyodbc.Row' and 'int'

1 Answer 1

6

Problem

The problem here is that you are assigning pyodbc.Row instance (returned by .fetchone()) to starting_index, which makes it impossible to add it to the integer (thus the "TypeError: unsupported operand type(s)" error).

Solution

Try to replace this line:

starting_index = cursor.fetchone()

with this line:

starting_index = cursor.fetchone()[0]

More reading

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.