-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathusers.py
More file actions
76 lines (61 loc) · 2.27 KB
/
users.py
File metadata and controls
76 lines (61 loc) · 2.27 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
69
70
71
72
73
74
75
76
import datetime
from os import error
import time
import sqlite3
current_date = datetime.date.today()
current_time = time.localtime()
year = current_time.tm_year
month = current_time.tm_mon
day = current_time.tm_mday
hour = current_time.tm_hour
minutes = current_time.tm_min
scheduled_time = year,month,day,hour,minutes
#print time as stringf
#print( f'{year}{month}{day}{hour}{minutes}')
#timer_set = f'{year}{month}{day}{hour}{minutes}'
class User:
#constructor
def __init__(self,email,password):
self.email = email
self.password = password
def user_login(self):
conn = sqlite3.connect('database.db')
db = conn.cursor()
db.execute("SELECT rowid, first_name, last_name, email, password, created_at FROM users where email = ? AND password = ?;",(self.email,self.password))
record = db.fetchall()
if(len(record) == 1):
response = "Login Successful"
return response
else:
response = "Error Login In"
return response
#print(record)
def user_details(self):
conn = sqlite3.connect('database.db')
db = conn.cursor()
db.execute("SELECT rowid, first_name, last_name, email, password, created_at FROM users where email = ? AND password = ?;",(self.email,self.password))
record = db.fetchall()
return record
#class will create user
class Create_user(User):
#constructor
def __init__(self,first_name,last_name,email,password,phone):
self.first_name = first_name
self.last_name = last_name
self.email = email
self.password = password
self.phone = phone
def create(self):
conn = sqlite3.connect('database.db')
db = conn.cursor()
try:
db.execute("INSERT INTO users (first_name,last_name,email,password,phone,created_at) VALUES (?,?,?,?,?,?)",(self.first_name,self.last_name,self.email,self.password,self.phone,current_date))
conn.commit()
response = "Account successfully created"
return response
except:
print(error)
#response = "Error creating account"
#return response
new_user = User('kahenyaa','qwerty')
reg_user = Create_user('john','kahenya','kahenyaa@gmail.com','qwerty','+254700419377').create()