-
Notifications
You must be signed in to change notification settings - Fork 92
Expand file tree
/
Copy pathdm_credentials.py
More file actions
24 lines (20 loc) · 860 Bytes
/
dm_credentials.py
File metadata and controls
24 lines (20 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
from connection import connection_handler
@connection_handler
def register_user(cursor, form_data, hashed_password):
# form_data.username.data, form_data.email.data etc...
cursor.execute("""
INSERT INTO users (username, name, email, password)
VALUES (%(username)s, %(name)s, %(email)s, %(password)s)
""", {'username': form_data.username.data,
'name': form_data.name.data,
'email': form_data.email.data,
'password': hashed_password})
@connection_handler
def get_user_data(cursor, email):
cursor.execute("""
SELECT * FROM users
WHERE email = %(email)s
""",
{'email': email})
user_data = cursor.fetchone()
return user_data