0

my problem is that I would like to retrieve a result set from the database with columns having different data types, it works fine with all data types except floating points.

I get this error" TypeError: Object of type 'Decimal' is not JSON serializable "

I read some solutions like https://stackoverflow.com/a/3885198/6079156 but I don't know how to use them to solve my problem. sample code:

from flask import render_template


def employee():

    # salary's data type is decimal(8,2) in the database
    cursor.execute("SELECT ID, dateofbirth, type, salary FROM employee")

    result= cursor.fetchall()

    return render_template('Employee.html', result=result)
Martin Gergov
  • 1,556
  • 4
  • 20
  • 29
Emma
  • 1
  • 5
  • 1
    Nothing in this code is serializing to JSON, so you need to show the code that is actually doing that as well as the full traceback. – Daniel Roseman Mar 14 '18 at 16:15
  • Thanks for replying! I had a session variable but for the sake of simplicity I removed it from here, little did I know that it caused the problem. – Emma Mar 14 '18 at 16:44

0 Answers0