5測試

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()

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章