I am using Python 2.7 and MySQLdb. I get this error in this code:
Value = 5 x.execute("SELECT number from Testing where id ='%s';" % Value) data = x.fetchall() print (data) data = data[0][0] data = data + 0.5 x.execute(""" UPDATE Testing SET number = %s WHERE id = %s """, (data, Value)) conn.commit()
Error on the line: data = data + 0.5 .
TypeError: unsupported operand type(s) for +: 'decimal' and 'float'.
The number is DECIMAL(8,1) . I saw other questions with this error, but not for adding. In addition, I think that some people will have the same problem if they are new to Python and cannot understand the more advanced Python encoding for such problematic issues. could you help me? Thanks in advance.
source share