Python 常用的mysql 语句

#检查表是否存在
show tables like 'user'

#创建表
create table if not exists user
(
id int auto_increment,
uname varchar(30) null,
pw varchar(100) null,
pw_md5 varchar(100) null,
constraint user_my_pk
unique (id)
)
# 删除表
drop table if exists user

# 插入数据
insert into user set uname = 'testname',pw= '1111'
insert into user (uname,pw) values ('testname','1111')

# 筛选数据
select * from user where uname = 'testname'

# 删除数据
delete from user_my where uname = 'meiyanTest2'

# 更新数据
UPDATE user_my SET pw="2222",pw_md5='3333' WHERE id=3

posted @ 2021-01-27 16:06  Mia妈妈加油呀  阅读(178)  评论(0)    收藏  举报