File "/root/anaconda3/envs/dbgpt_env/lib/python3.10/site-packages/fastapi/encoders.py", line 230, in jsonable_encoder
data = dict(obj)
TypeError: cannot convert dictionary update sequence element #0 to a sequence
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/root/anaconda3/envs/dbgpt_env/lib/python3.10/site-packages/fastapi/encoders.py", line 235, in jsonable_encoder
data = vars(obj)
TypeError: vars() argument must have dict attribute
4条答案
按热度按时间ercv8c1e1#
看日志不太看的出来, 可能是生产的sql 里一些特殊符号 导致解析出来的参数有问题, 可能需要debug下
qlzsbp2j2#
这个解决了吗?
sqyvllje3#
在
conn.query_ex
函数中,将result = list(result)
修改为result = list(map(lambda x: x._data, result))
即可通过。vs3odd8k4#
@Gj-12222 请问
try:
sql_query_result = db.execute(results).fetchall()
db.commit()
except Exception as e:
db.rollback()
logger.error(f"Database error: {str(e)}")
这种想把模型输出结果直接连接数据库执行的情况下,报错:ValueError('dictionary update sequence element #0 has length 32; 2 is required'), TypeError('vars() argument must have dict attribute') 应该如何解决?