python查询mysql数据库,执行sql后查询结果数据类型为Decimal,解决方法

案例一:

使用python查询mysql:select  money from amount where amount_id="1001"

此时查询出的money结果为10000,类型为Decimal。

无法进行后续的运算和字符串拼接操作。

解决方法:

将sql改造为:select CAST(money as CHAR) as money from amount where amount_id="1001"

此时查询出的money结果为10000,类型为str。

后续可将str转换为int或直接拼接

posted @ 2021-06-17 12:43  Chaman囍  阅读(2067)  评论(0编辑  收藏  举报