'numpy.float64' object has no attribute 'translate' Inserting value to Mysql in Python

前端 未结 4 760
庸人自扰
庸人自扰 2021-02-14 15:00
import dataset
db = dataset.connect(....)
table = db[...]

When I try to insert some value into Mysql table, this error occurred.

Sample Value

4条回答
  •  离开以前
    2021-02-14 15:36

    Add the command below to anywhere before making pymysql connection. It adds new encoder of numpy.float64.

    pymysql.converters.encoders[np.float64] = pymysql.converters.escape_float
    pymysql.converters.conversions = pymysql.converters.encoders.copy()
    pymysql.converters.conversions.update(pymysql.converters.decoders)
    

提交回复
热议问题