import sqlite3
connect=sqlite3.connect(“testsqlite.db”)
cursor =connect.cursor()
cursor.execute("""
SELECT id,name,sex,phone from employee
“”")
employee_list = cursor.fetchall()
print(employee_list)cursor.execute("""
SELECT * from employee WHERE sex=‘男’
“”")
employee_jj = cursor.fetchall()
print(employee_jj)
假性删除,为了防止数据误删和方便找回。专门新建一个标识字段表示用户(正常、注销)
cursor.execute("""
update employee set del_flag=1 where name=“小红”;
“”")
connect.commit()
cursor.execute("""
SELECT * FROM employee where del_flag=0;
“”")
connect.close()
个人学习记录