Problem with python prepared stmt parameter passin

2019-09-21 02:00发布

问题:

File C:\Users\User\AppData\Local\Programs\Python\Python37\lib\site-packages\mysql\connector\cursor.py, line 1149, in execute elif len(self._prepared[parameters]) != len(params): TypeError: object of type int has no len()

回答1:

The problem is python make error when we pass single parameter we need to put comma(,) at the end of first parameter. like the follwoing

input=(customerId,)
cursor.execute(sql, input)