python 操作sqlite3 查询 删除 添加操作

作者: shaoliang 2020-04-11 09:46   访问数:635

import sqlite3

conn = sqlite3.connect("/home/sl/2.db")
c = conn.cursor()
# c.execute("drop table login")
# c.execute('create table login (id integer primary key, name varchar(30), password varchar(30))')
# conn.commit()


# name1=input("输入名字:")
#
# name1="ttt"
# sql = "insert into login('name') values ('"+name1+"')"
# c.execute(sql)
# conn.commit()

sql="delete  from login where id=1"
c.execute(sql)
conn.commit()

c.execute("select * from login  order by id desc")
for r in c.fetchall():
    a = r[0]
    b = r[1]

    print(a)

c.close()
conn.close()


鲁ICP备19029146号-1 管理
CopyRight@51dr.top 页面打开时间 0.0307 秒.