1 Star 0 Fork 0

Python程序设计/20194312 蔡永健

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
数据库sqlite3.py 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
Qze20194312蔡永健 提交于 2020-04-29 22:35 . sqlite3数据库
'''
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()
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/python_programming/cyj20194312__cai_yongjian.git
[email protected]:python_programming/cyj20194312__cai_yongjian.git
python_programming
cyj20194312__cai_yongjian
20194312 蔡永健
master

搜索帮助