-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreconcile.py
More file actions
54 lines (33 loc) · 1.44 KB
/
reconcile.py
File metadata and controls
54 lines (33 loc) · 1.44 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
# Author: Reid Moline
import sqlite3
def create_empty_reconcile_table():
'''
Function that connects to the database bikeshop.sqlite and creates an empty table Reconcile used to track inventory issues that need to be addressed
Parameters: None
Returns: None
'''
connection = sqlite3.connect('bikeshop.sqlite') # Creates a connection to the database
cursor = connection.cursor()
cursor.execute("PRAGMA foreign_keys = ON")
cursor.execute("""CREATE TABLE IF NOT EXISTS Reconcile
(Issue_ID INT,
UPC INT,
Date TEXT,
Fixed INT DEFAULT '0',
PRIMARY KEY (Issue_ID),
FOREIGN KEY (UPC) REFERENCES Products (UPC)
)""")
if __name__ == "__main__":
conn = sqlite3.connect('bikeshop.sqlite')
cur = conn.cursor()
cur.execute("PRAGMA foreign_keys = ON")
cur.execute("SELECT UPC FROM Reconcile WHERE Fixed = 0;")
unfixed_inventory_issues = cur.fetchall()
if len(unfixed_inventory_issues) != 0:
print("UPC's with negative quantity showing")
print('_' * 20 + '\n')
for i in range(len(unfixed_inventory_issues)):
print(unfixed_inventory_issues[i][0]) # Prints out each upc from
# For you TODO Given this list of issues try and create queries to fix the quantity to be 0 and don't forget to close the issue
conn.commit()
conn.close()