sqlalchemy搭配mysqlconnector和pymysql时遇到的问题记录

使用 sqlachemy + pymysql

D:\ProgramData\Anaconda3\lib\site-packages\pymysql\cursors.py:170: Warning: (1366, "Incorrect string value: '\\xD6\\xD0\\xB9\\xFA\\xB1\\xEA...' for column 'VARIABLE_VALUE' at row 484")
  result = self._query(query)

使用sqlachemy + mysqlconnector

Traceback (most recent call last):
  File "D:\ProgramData\Anaconda3\lib\site-packages\mysql\connector\conversion.py", line 179, in to_mysql
    return getattr(self, "_{0}_to_mysql".format(type_name))(value)
AttributeError: 'MySQLConverter' object has no attribute '_tuple_to_mysql'
...
...
...
sqlalchemy.exc.ProgrammingError: (mysql.connector.errors.ProgrammingError) Failed processing pyformat-parameters; Python 'tuple' cannot be converted to a MySQL type [SQL: 'UPDATE game_daily_details SET in_app_times=%(in_app_times)s, in_app_amount=%(in_app_amount)s, in_app_origin_amount=%(in_app_origin_amount)s, in_app_fxrate=%(in_app_fxrate)s, in_app_currency=%(in_app_currency)s, updated_at=%(updated_at)s WHERE game_daily_details.id = %(game_daily_details_id)s'] [parameters: {'in_app_times': (1.0,), 'in_app_amount': (4.199999999999999,), 'in_app_origin_amount': (4.199999999999999,), 'in_app_fxrate': (1,), 'in_app_currency': ('USD',), 'updated_at': datetime.datetime(2019, 3, 11, 12, 11, 37, 573225, tzinfo=), 'game_daily_details_id': 1}] (Background on this error at: http://sqlalche.me/e/f405)

最开始用pymsql遇到如上的一条警告信息,然后改用mysqlconnector,接下来就是漫长的诡异了,无法使用,报错信息如上,一直以为是自己传了tuple参数给sql,其实问题不在我这里,最后又改回pymysql,除了还是有条警告,功能一切正常。

你可能感兴趣的:(Python使用)