-
Notifications
You must be signed in to change notification settings - Fork 107
Expand file tree
/
Copy pathcreateAccountRow.py
More file actions
62 lines (45 loc) · 1.41 KB
/
createAccountRow.py
File metadata and controls
62 lines (45 loc) · 1.41 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
from mysql import connector
from mysql.connector import errorcode
import mysql
def addNewUser( firstName,
lastName,
userEmail,
phoneNumber,
password,
PatientOrProvider,
dbConnection
):
returnVal = 1
addUser = ("INSERT INTO users"
"(Email, First_Name, Last_Name, PasswordHash, Phone_Number, PatientOrProvider)"
"VALUES ((%(EmailVal)s)," \
"(%(First_NameVal)s)," \
"(%(Last_NameVal)s)," \
"(%(PasswordVal)s)," \
"(%(Phone_NumberVal)s)," \
"(%(PatientOrProviderVal)s))"
)
dataUser = {
'EmailVal': userEmail,
'First_NameVal': firstName,
'Last_NameVal': lastName,
'PasswordVal': password,
'Phone_NumberVal': phoneNumber,
'PatientOrProviderVal': PatientOrProvider
}
cursor = dbConnection.cursor()
try:
cursor.execute(addUser, dataUser)
except mysql.connector.Error as err:
if err.errno == 1062:
returnVal = 2
try:
dbConnection.commit()
except mysql.connector.Error as err:
if err.errno == 1062:
returnVal = 3
cursor.close() # close cursor
dbConnection.close() # close connection
return returnVal
def addNewUserTest():
print("import successful! :)")