python连接mysql数据库报错pymysql连接数据库报错TypeError: __init__() takes 1 positional argument but 5 positional arguments


1、

https://blog.csdn.net/msq16021/article/details/113617327

 

一开始都是这么简单的写,并无报错
db = pymysql.connect("localhost", "root", "196811", "db_student",charset="utf8")
return db # 返回连接对象
迁移服务后,可能是因为mysql版本或者pymysql的版本有变化,导致不能再这么简单的写了,传参规则变得规范了
主要就是将传参的参数名加上
db = pymysql.connect(host="localhost", user="root", password="196811", database="db_student",charset="utf8mb4")


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM