该部分的内容需要有一定基础,如果需要了解基础的话,点击链接------>Python操作Mysql数据库步骤以及常用方法
1、增加数据
- 关键字:insert into
sql = ”insert into news(title,content) values('今天发生了一件大事','狗丢了')“
result = link.execute(sql)
db.commit()
2、修改数据
- 关键字:update
sql = “update news set content='狗找到了' where id=1”
result = link.execute(sql)
db.commit()
3、查看数据
- 关键字:select
sql = "select * from student"
result = link.execute(sql)
data =link.fetchall()
print(data)
4、删除数据
- 关键字:delete
sql = "ddelete from studnet news where id=1"
result = link.execute(sql)
print(result)
本文详细介绍使用Python对MySQL数据库进行增删改查的具体操作步骤及常用方法。包括如何插入、更新、查询和删除数据,为读者提供实用的代码示例。
469

被折叠的 条评论
为什么被折叠?



