該部分的內容需要有一定基礎,如果需要了解基礎的話,點擊鏈接------>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)