-
Notifications
You must be signed in to change notification settings - Fork 1
/
userDB.py
43 lines (36 loc) · 1.15 KB
/
userDB.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
import sqlite3
from sqlite3 import Error
class User:
def __init__(self, email, password, name,
zipcode, rating, transaction_count, phone_number):
self.email = email
self.password = password
self.name = name
self.zipcode = zipcode
self.rating = rating
self.transaction_count = transaction_count
self.phone_number = phone_number
def get_password(self):
return self.password
def get_name(self):
return self.name
def get_email(self):
return self.email
def select_user_by_email(email: str) -> User:
try:
conn = sqlite3.connect("sqlite_db")
users = conn.execute(
"Select * from User where email = ?", (email,)
).fetchall()
conn.commit()
print(users)
if len(users) != 1:
return None
else:
email, password, name, zipcode, \
rating, transaction_count, phone_number = users[0]
return User(email, password, name, zipcode,
rating, transaction_count, phone_number)
except Error as e:
print(e)
return None