Ervan uitgaande dat u mysql.connector
. gebruikt (Ik denk van wel), definieer je eigen converterklasse:
class NumpyMySQLConverter(mysql.connector.conversion.MySQLConverter):
""" A mysql.connector Converter that handles Numpy types """
def _float32_to_mysql(self, value):
return float(value)
def _float64_to_mysql(self, value):
return float(value)
def _int32_to_mysql(self, value):
return int(value)
def _int64_to_mysql(self, value):
return int(value)
config = {
'user' : 'user',
'host' : 'localhost',
'password': 'xxx',
'database': 'db1'
}
conn = mysql.connector.connect(**config)
conn.set_converter_class(NumpyMySQLConverter)