报错一:
raise err.InterfaceError("(0, '')")
pymysql.err.InterfaceError: (0, '')
数据库打开后直接关闭了,执行sql查询时报错,解决方法:借鉴同学:https://blog.csdn.net/lluozh2015/article/details/78411884
报错二:
TypeError: selectSQL() missing 1 required positional argument: 'self'
解决方法:需要定义一个实例,使用实例来调用方法
# -*- coding:utf8 -*- import pymysql host = '10.96.114.13' class database: def __init__(self): print("init mysql") # 打开数据库连接 self.db = pymysql.connect(host=host, port=3306, user='root', passwd='123456', db='ibt_confucius_db') # 使用 cursor() 方法创建一个游标对象 cursor self.cursor = self.db.cursor() def closeDB(self): self.cursor.close() self.db.close() print("cl