python实现学生管理系统(mysql+面向对象)
from pymysql import *
class Mysql():
def __init__(self):
self.conn=connect(user="root", password="malong1", port=3306, host="localhost", database="jian", charset="utf8")
self.cur=self.conn.cursor()
def __del__(self):
self.cur.close()
self.conn.close()
def set_sql(self,sql="",prm=()):
self.cur.execute(sql,prm)
if "select" in sql:
result=self.cur.fetchall()
else:
self