1 Star 0 Fork 0

wangDong/db2

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
test01.py 819 Bytes
一键复制 编辑 原始数据 按行查看 历史
wangDong 提交于 2020-10-26 17:27 . 新增了增删改查
import pymysql
def main():
no=input('请输入你要删除的学生!')
conn=pymysql.connect(host='39.98.119.160',port=3306,
user='root',password='123456',
db='school',charset='utf8')
try:
with conn.cursor() as cursor:
# result=cursor.execute('insert into tb_student values(1012,"杨大小",1,"2020-1-1","永州",1)')
result=cursor.execute(
'delete from tb_student where stuid=%s',(no,)
)
if result==1:
# print('添加成功')
print('删除成功')
conn.commit()
except pymysql.MySQLError as error:
print(error)
conn.rollback()
finally:
conn.close()
if __name__=='__main__':
main()
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/wd1220/db2.git
git@gitee.com:wd1220/db2.git
wd1220
db2
db2
master

搜索帮助

D67c1975 1850385 1daf7b77 1850385