-
Notifications
You must be signed in to change notification settings - Fork 17
/
Delete Clause.py
37 lines (34 loc) · 1.19 KB
/
Delete Clause.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import sqlite3
print("DELETING RECORD WITH ID = 6")
db = sqlite3.connect("assets/Student_records.db")
query = """DELETE FROM Student_Records WHERE ID = 6"""
cursor = db.cursor()
cursor.execute(query)
db.commit()
query = """SELECT * FROM Student_Records"""
cursor.execute(query)
student_record = cursor.fetchall()
for id, names, marks, grades in student_record:
print(id, names, marks, grades)
print("\nDELETING RECORDS WHERE THE NAMES START WITH S")
db = sqlite3.connect("assets/Student_records.db")
query = """DELETE FROM Student_Records WHERE NAMES LIKE 's%'"""
cursor.execute(query)
db.commit()
query = """SELECT * FROM Student_Records ORDER BY NAMES ASC"""
cursor.execute(query)
student_record = cursor.fetchall()
for id, names, marks, grades in student_record:
print(id, names, marks, grades)
print("\nDELETING ALL THE RECORDS IN THE TABLE")
db = sqlite3.connect("assets/Student_records.db")
query = """DELETE FROM Student_Records """
cursor.execute(query)
db.commit()
query = """SELECT * FROM Student_Records"""
cursor.execute(query)
student_record = cursor.fetchall()
for id, names, marks, grades in student_record:
print(id, names, marks, grades)
db.close()
input("Press Enter key to exit ")