phidatahq / phidata

Build AI Assistants with memory, knowledge and tools.
https://docs.phidata.com
Mozilla Public License 2.0
10.45k stars 1.51k forks source link

[SQLtools] fix exception "Object of type datetime is not JSON serializable" with MySQL server #976

Closed D3fau4 closed 1 month ago

D3fau4 commented 1 month ago

As we discussed on discord, when using sqltools if you connect it to a MySQL server it gives error when trying to serialize a datetime field and this could be easily avoided by giving a default when serializing the results to json.

return json.dumps(self.run_sql(sql=query, limit=limit), default=str)