使用modify修改字段报错如下: mysql> alter table student modify name sname char(16);ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'sname char(16)' at line…
第一种:拼接字符串,可以解决问题,但是为了避免sql注入,不建议这样写 还是看看第二种:使用.format()函数,很多时候我都是使用这个函数来对sql参数化的 举个例子: select * from XX where id in (1,2,3) 参数化in里面的值: select * from XX where id in ({}).format('1,2,3') 你可以打印下看看,和你原来的sql是一模一样的 补充知识:python与mysql交互/读取本地配置文件/交互报错 如果自己写my…
原文:https://cenalulu.github.io/mysql/mysql-has-gone-away/ MySQL Server has gone away报错原因汇总分析 原因1. MySQL 服务宕了 原因2. 连接超时 原因3. 进程在server端被主动kill 原因4. Your SQL statement was too large. 本文将总结和汇总MySQL Server has gone away这类报错发生的原因 背景:在平时和开发的交流 以及 在论坛回答问题的或称…