-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathback.py
48 lines (40 loc) · 2 KB
/
back.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
38
39
40
41
42
43
44
45
46
47
import sqlite3
def connect():
connection=sqlite3.connect("crime.db")
cur=connection.cursor()
cur.execute("CREATE TABLE IF NOT EXISTS crime_record( Criminal_id PRIMARY KEY,Name text,Gender text,Nationality text,Age integer,Height float,Weight float,Crime_Committed text)")
connection.commit()
# connection.close()
def insert(Criminal_id,Name,Gender,Nationality,Age,Height,Weight,Crime_Committed):
connection=sqlite3.connect("crime.db")
cur=connection.cursor()
cur.execute("INSERT INTO crime_record VALUES (?, ?, ?, ?, ?, ?, ?, ?)",(Criminal_id , Name , Gender , Nationality , Age , Height , Weight , Crime_Committed))
connection.commit()
# connection.close()
def view():
connection=sqlite3.connect("crime.db")
cur=connection.cursor()
cur.execute("SELECT * FROM crime_record ")
rows=cur.fetchall()
# connection.close()
return rows
def search(Criminal_id="",Name="",Gender="",Nationality="",Age="",Height="",Weight="",Crime_Committed=""):
connection=sqlite3.connect("crime.db")
cur=connection.cursor()
cur.execute("SELECT * FROM crime_record WHERE Criminal_id=? OR Name=? OR Gender=? OR Nationality=? OR Age=? OR Height=? OR Weight=? OR Crime_Committed=? ",(Criminal_id,Name,Gender,Nationality,Age,Height,Weight,Crime_Committed))
rows=cur.fetchall()
# connection.close()
return rows
def delete(Criminal_id):
connection=sqlite3.connect("crime.db")
cur=connection.cursor()
cur.execute("DELETE FROM crime_record WHERE Criminal_id=?",(Criminal_id,))
connection.commit()
# connection.close()
def update(Criminal_id,Name,Gender,Nationality,Age,Height,Weight,Crime_Committed):
connection=sqlite3.connect("crime.db")
cur=connection.cursor()
cur.execute("UPDATE crime_record SET Criminal_id=?,Name=?,Gender=?,Nationality=?,Age=?,Height=?,Weight=?,Crime_Committed=? WHERE Criminal_id=?",(Criminal_id,Name,Gender,Nationality,Age,Height,Weight,Crime_Committed,Criminal_id))
connection.commit()
# connection.close()
connect()