Issues with data return by raw sql query in Django

763 Views Asked by At

I am fetching data from db using raw SQl queries , I am following these django docs. As you can see in django docs we have a function dictfetchall which returns dict with field names and values. I am converting this dict to json as per my requirements but as you can see in output cursor return values with unicode like

> 54360982L
> for date - datetime.date(2015, 8, 3)
> for decimal - Decimal('0.63')

Thus dict cannot be convert into json as it will raise error Decimal('0.63') is not JSON serializable . So How i can prevent raw sql to sent simple values from db or need to edit dictfetchall function , if yes then where ?

0

There are 0 best solutions below