昆山到南京多远:conn.execute("")(如何插入新记录)

来源:百度文库 编辑:高校问答 时间:2024/05/05 06:36:53
conn.execute("")如何插入一条新数据
conn.execute("")如何修改记录
conn.execute("")如何删除记录

关键是“”中的sql命令
插入用:
insert into 表名 values (括号内写出各属性值)
例:insert into Students values('xiaoming','class 3')

修改用:
update 表名
set 属性=新属性值
where 条件
例:update Students
set class='class 4'
where name='xiaoming'

删除用
delete from 表名 where 条件
例:delete from Students where name='xiaoming'

条件可用and or并列
条件中的not可表示“除此之外”

conn.execute(sql)

sql = delete from 表