说明
使用此方法,传值和返回查询结果,一般除了整数外,都是byte类型,需要做额外处理,所以暂不要用此方法
而且中文网站中没有用预编译方式的
官网链接:
https://dev.mysql.com/doc/connector-python/en/connector-python-api-mysqlcursorprepared.html
例子:
cursor = cnx.cursor(prepared=True)
stmt = "SELECT fullname FROM employees WHERE id = %s"
cursor.execute(stmt, (5,))
注意: SQL 的占位符是 %s