db = pymysql.connect(host='localhost',
user='root',
password='password',
database='test',
charset='utf8',
autocommit=False)
cursor = db.cursor()
ins = cursor.fetchall()
如上方式是错的,会导致报错
execute()first
db = pymysql.connect(host='localhost',
user='root',
password='password',
database='test',
charset='utf8',
autocommit=False)
cursor = db.cursor()
#select 表示数据库查询语句
cursor.execute('select')
info = cursor.fetchall()
这个方式才是对的
也就是说fetchall本身并不是个查找数据的函数,他的作用只是把你找出来的数据拿出来