Python学生管理系统(控制台版)

使用Python 3.7和MySQL,构建了一个学生管理系统的控制台版本,具备学生信息的增删改查功能。项目详细说明可在指定链接中查看,包括项目结构、BaseDao类、Student类以及主程序的实现。运行程序展示直观的用户交互界面。
摘要由CSDN通过智能技术生成

工具: Python 3.7
pycharm
mysql
本项目是对学生的基本增删改查(控制台版)
项目功能演示:https://download.csdn.net/download/zeal9s/10737062
项目的基本要求:https://blog.csdn.net/zeal9s/article/details/83274119
项目基本结构图:
在这里插入图片描述
dao包中的BaseDao类:

# -*- encoding:utf-8 -*-
"""
@作者:小思
@文件名:BaseDao.py
@时间:2018/10/19  8:51
@文档说明:连接数据库和关闭数据库的方法
"""
import pymysql
import com.zs.entity.Student as student

s = student.Student()


# 1.查询所有学生信息
def getAll():
    connect = pymysql.connect(host="192.168.43.21", user="user", passwd="1234", db="zs")
    cursor = connect.cursor()
    cursor.execute("select * from Student")
    data = cursor.fetchall()
    connect.close()
    return data


# 根据学生姓名查询学生信息
def getStudentBySname(s):
    connect = pymysql.connect(host="192.168.43.21", user="user", passwd="1234", db="zs")
    cursor = connect.cursor()
    sql = "select *  from Student where sname='%s'" % (s.getSname())
    cursor.execute(sql)
    data = cursor.fetchall()
    connect.close()
    return data


# 根据sid查询单个学生信息
def getStudentBySid(s):
    connect = pymysql.connect(host="192.168.43.21", user="user", passwd="1234", db="zs")
    cursor = connect.cursor()
    sql = "select *  from Student where sid=%d" % (s.getSid())
    cursor.execute(sql)
    data = cursor.fetchone()
    connect.close()
    return data


# 添加学生信息
def addStudent(s):
    connect = pymysql.connect(host="192.168.43.21", user="user", passwd="1234", db="zs")
    cursor = connect.cursor()
    sql = "insert into Student values(null,'%s','%s','%d')" % (s.getSname(), s.getSsex(), s.getSage())
    cursor.execute(sql)
    connect.commit()
    connect.close()


# 删除学生信息
def delStudent(s):
    connect = pymysql.connect(host="192.168.43.21", user="user", passwd="1234", db="zs")
    cursor = connect.cursor()
    sql = "delete from Student where sid=%d" % (s.getSid())
    cursor.execute(sql)
    connect.commit()
    connect.close()


# 修改学生信息
def updStudent(s):
    connect = pymysql.connect(host="192.168.43.21", user="user", passwd="1234", db=
评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值