You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
print("\033[1;31;40m Error username or password.Plese try again\033[1;37;40m\n")
25
-
else:
26
-
#connect to database
27
-
mydb=mysql.connector.connect(
28
-
host='localhost', #or your hostname/ip-address
29
-
user=(user),
30
-
password=(passwd)
31
-
)
32
-
33
-
#set cursor
34
-
mycursor=mydb.cursor(buffered=True)
35
-
d=mydb.cursor(buffered=True)
36
-
i=mydb.cursor(buffered=True)
37
-
38
-
#detect and create database
39
-
mycursor.execute('CREATE DATABASE IF NOT EXISTS db_password')
40
-
mycursor.execute('CREATE TABLE IF NOT EXISTS db_password.tb_nap (id INT NOT NULL AUTO_INCREMENT,name VARCHAR(255) NOT NULL,password VARCHAR(255) NOT NULL,PRIMARY KEY (id))')
41
-
42
-
#interfaces
43
-
print("\n\nWelcome to password manager python! what you want to do?(v to view all your password,i to insert,d to delete")
44
-
cmd=input(">")
45
-
46
-
#view query
47
-
ifcmd=='v'orcmd=='V':
48
-
mycursor.execute("SELECT id, name FROM db_password.tb_nap") #select id,name from database
49
-
myresult=mycursor.fetchall()
50
-
51
-
iflen(myresult)==0: #detect blank input
52
-
print("Nothing here\n")
53
-
else:
54
-
print("What you wanna see?")
55
-
forxinmyresult :
56
-
print(x)
57
-
58
-
icmd=input("Enter ID:")
59
-
ificmd=='':
60
-
print("\033[1;31;40m Error id. \033[1;37;40m\n")
18
+
defenter():
19
+
#enter user and password for database and master password
print("\033[1;31;40m Error username or password.Plese try again\033[1;37;40m\n")
28
+
enter()
29
+
else:
30
+
#connect to database
31
+
mydb=mysql.connector.connect(
32
+
host='localhost', #or your hostname/ip-address
33
+
user=(enter.user),
34
+
password=(enter.passwd)
35
+
)
36
+
37
+
#set cursor
38
+
mycursor=mydb.cursor(buffered=True)
39
+
d=mydb.cursor(buffered=True)
40
+
i=mydb.cursor(buffered=True)
41
+
42
+
#detect and create database
43
+
mycursor.execute('CREATE DATABASE IF NOT EXISTS db_password')
44
+
mycursor.execute('CREATE TABLE IF NOT EXISTS db_password.tb_nap (id INT NOT NULL AUTO_INCREMENT,name VARCHAR(255) NOT NULL,password VARCHAR(255) NOT NULL,PRIMARY KEY (id))')
45
+
46
+
#interfaces
47
+
print("\n\nWelcome to password manager python! what you want to do?(v to view all your password,i to insert,d to delete,q to exit)")
48
+
cmd=input(">")
49
+
50
+
#view query
51
+
ifcmd=='v'orcmd=='V':
52
+
mycursor.execute("SELECT id, name FROM db_password.tb_nap") #select id,name from database
53
+
myresult=mycursor.fetchall()
54
+
55
+
iflen(myresult)==0: #detect blank input
56
+
print("Nothing here\n")
57
+
else:
58
+
print("What you wanna see?")
59
+
forxinmyresult :
60
+
print(x)
61
+
62
+
icmd=input("Enter ID:")
63
+
ificmd=='':
64
+
print("\033[1;31;40m Error id. \033[1;37;40m\n")
65
+
else:
66
+
d.execute("SELECT id,name FROM db_password.tb_nap WHERE id= %s",(icmd,)) #select id,name from id input
67
+
i.execute("SELECT password FROM db_password.tb_nap WHERE id= %s",(icmd,)) #select password from id input
68
+
p=d.fetchall()
69
+
i=i.fetchall()
70
+
password=" , ".join( map(str, i) ) #transition list to string
71
+
72
+
k_encode=enter.k.encode() #encode key to byte
73
+
p_encode=password.encode() #encode password to byte
0 commit comments