db/mysql_data.py
@@ -4,16 +4,9 @@ import pymysql # 把连接参数定义成字典 import constant config = { "host": "127.0.0.1", "port": 3306, "database": "gp", "charset": "utf8", "user": "root", "passwd": "123456" } config = constant.MYSQL_CONFIG class Mysqldb: # 初始化方法 @@ -23,6 +16,9 @@ # 调用获取游标的方法 self.cursor = self.get_cursor() def close(self): self.conn.close() # 连接数据库的方法 def get_conn(self): # **config代表不定长参数