-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsqll.py
More file actions
68 lines (54 loc) · 2.08 KB
/
Copy pathsqll.py
File metadata and controls
68 lines (54 loc) · 2.08 KB
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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
import sqlite3
import json
def add_user(type, password, name):
con = sqlite3.connect('data/instance/sportequip.db')
cur = con.cursor()
cur.execute("""INSERT INTO user (type, password, name)
VALUES (?, ?, ?)
""", (type, password, name,))
con.commit()
return True
def add_procurements(name, count, status):
con = sqlite3.connect("data/instance/sportequip.db")
cur = con.cursor()
cur.execute("""INSERT INTO procurements (name, count, status)
VALUES (?, ?, ?)
""", (name, count, status,))
con.commit()
return True
def add_item(name, count, state, admin):
con = sqlite3.connect("data/instance/sportequip.db")
cur = con.cursor()
cur.execute("""INSERT INTO inventory (name, count, state, admin)
VALUES (?, ?, ?, ?)
""", (name, count, state, admin,))
con.commit()
return True
def delete_item(name):
con = sqlite3.connect("data/instance/sportequip.db")
cur = con.cursor()
cur.execute("""DELETE FROM inventory WHERE name=?
""", (name,))
con.commit()
return True
def delete_user(name):
con = sqlite3.connect("data/instance/sportequip.db")
cur = con.cursor()
cur.execute("""DELETE FROM user WHERE name=?
""", (name,))
con.commit()
return True
def update_item(name, new_count):
con = sqlite3.connect("data/instance/sportequip.db")
cur = con.cursor()
cur.execute("""UPDATE inventory SET count=? WHERE name=?
""", (new_count, name,))
con.commit()
return True
def update_user(name, new_password):
con = sqlite3.connect("data/instance/sportequip.db")
cur = con.cursor()
cur.execute("""UPDATE user SET password=? WHERE name=?
""", (new_password, name))
con.commit()
return True