0

I have a problem. Im using redshift_connector to connect to AWS RedShift. Result of my query is tuple. How can change type to json? The problem is that one column is a date and I got a error

"TypeError" Object of type date is not JSON serializable.

conn = redshift_connector.connect(
    host='',
    database='',
    user='',
    password=''
)

cursor: redshift_connector.Cursor = conn.cursor()
cursor.execute("")
columns = cursor.description
result = [{columns[index][0]:column for index, column in enumerate(value)} for value in cursor.fetchall()]
payload = json.dumps(result)

adding default=str to json.dumps but its not a solution I expect that I will get json which I can use as a payload to POST request

mrnobody
  • 15
  • 4

0 Answers0