AttributeError: 'numpy.float64' object has no attribute 'translate'

AttributeError: ‘numpy.float64’ object has no attribute ‘translate’

from sqlalchemy import event
import numpy as np
import sqlalchemy

engine = sqlalchemy.create_engine(...)

def add_own_encoders(conn, cursor, query, *args):
    cursor.connection.encoders[np.float64] = lambda value, encoders: float(value)
# 解决方法
event.listen(engine, "before_cursor_execute", add_own_encoders)

你可能感兴趣的:(python)