-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdetails_db.py
81 lines (56 loc) · 1.66 KB
/
details_db.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
import sqlite3
# Create sqlite database connection
conn = sqlite3.connect('details.db')
cur = conn.cursor()
# Create database to store customer details
# cur.execute("""
# CREATE TABLE customer_details(
# email text,
# clientId text,
# secret text,
# ref text
# )""")
# Delete all customer entries from database
# cur.execute("DELETE from customer_details")
# Delete entire table
# cur.execute("DROP TABLE customer_details")
conn.commit()
conn.close()
# Create a customer record in database
def create_record(email, clientId, secret_number, ref):
conn = sqlite3.connect('details.db')
cur = conn.cursor()
cur.execute('INSERT INTO customer_details VALUES(:email,:clientId,:secret_number,:ref)',
{
'email': email,
'clientId': clientId,
'secret_number': secret_number,
'ref': ref
})
conn.commit()
conn.close()
# Fetch image refernces from database
def fetch_references():
refernces = []
conn = sqlite3.connect('details.db')
cur = conn.cursor()
cur.execute("SELECT ref FROM customer_details")
rows = cur.fetchall()
for row in rows:
print(row[0])
refernces.append(row[0])
print()
conn.commit()
conn.close()
return refernces
# Fetch customer details for a match
def fetch_payment_details(img_ref):
conn = sqlite3.connect('details.db')
cur = conn.cursor()
cur.execute("SELECT * FROM customer_details WHERE ref=?", (img_ref,))
row = cur.fetchall()
print('Customer details are --------')
print(row)
conn.commit()
conn.close()
return row