代码拉取完成,页面将自动刷新
'''
sqlite3 数据库实践
20194312 蔡永健
'''
import sqlite3
database = sqlite3.connect("NBA球星数值") #建立数据库
season = database.cursor() #建立游标对象
season.execute('create table if not exists player(name varchar(20) primary key,height int(10),weight float,team varchar(20))') #建立表格
season.execute('insert into player(name,height,weight,team) values("鲍班·马亚诺维奇",221,131.5,"底特律活塞")') #插入数据
season.execute('insert into player(name,height,weight,team) values("伊塞亚·托马斯",175,83.9,"波士顿凯尔特人")')
season.execute('insert into player(name,height,weight,team) values("波尔津吉斯",221,108.9,"纽约尼克斯")')
season.execute('select * from player')
print("修改前",season.fetchall())
print("="*20,"开始修改","="*20)
season.execute('update player set team = "洛杉矶快船" where name = "波尔津吉斯"') #修改数据
season.execute('update player set team = "芝加哥公牛" where name = "鲍班·马亚诺维奇"')
season.execute('delete from player where height = 175') #删除数据
season.execute('select * from player')
print("修改后",season.fetchall())
database.close()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。