Ако приемем, че използвате mysql.connector
(Мисля, че сте), дефинирайте свой собствен клас на конвертор:
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)