MySQLdb.Error报错
来源:3-4 python更新mysql数据
慕数据0164170
2019-07-01
用的vscode,报错代码如下
import MySQLdb
class MysqlSearch(object):
def __init__(self):
self.get_conn()
def get_conn(self):
try:
self.conn = MySQLdb.connect(
host='127.0.0.1',
user='root',
passwd='root',
db='news',
port=3308,
charset='utf8'
)
except MySQLdb.Error as e:
print('Error: %s' % e)
def close_conn(self):
try:
if self.conn:
# 关闭链接
self.conn.close()
except MySQLdb.Error as e:
print('Error: %s' % e)
报错为
但是我看了下官方文档,明明有这个member啊
写回答
1回答
-
NavCat
2019-07-02
pip install mysqlclient
卸载后重新安装一下012019-07-02
Python操作三大主流数据库-MySQL+MongoDB+Redis
一次实战同时掌握Python操作MySQL,MongoDB,Redis 三大数据库使用技巧
2024 学习 · 376 问题
相似问题