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
mycursor.execute('CREATE DATABASE IF NOT EXISTS db_password')
30
-
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))')
31
-
32
-
#interfaces
33
-
print("\n\nWelcome to password manager python! what you want to do?(v to view all your password,i to insert,d to delete")
34
-
cmd=input(">")
35
-
36
-
#view query
37
-
ifcmd=='v'orcmd=='V':
38
-
mycursor.execute("SELECT id, name FROM db_password.tb_nap") #select id,name from database
39
-
myresult=mycursor.fetchall()
40
-
41
-
iflen(myresult)==0: #detect blank input
42
-
print("Notthing here\n")
43
-
else:
44
-
print("What you wanna see?")
45
-
forxinmyresult :
46
-
print(x)
47
-
48
-
icmd=input("Enter ID:")
49
-
ificmd=='':
50
-
print("\033[1;31;40m Error id. \033[1;37;40m\n")
18
+
#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")
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")
61
+
else:
62
+
d.execute("SELECT id,name FROM db_password.tb_nap WHERE id= %s",(icmd,)) #select id,name from id input
63
+
i.execute("SELECT password FROM db_password.tb_nap WHERE id= %s",(icmd,)) #select password from id input
64
+
p=d.fetchall()
65
+
i=i.fetchall()
66
+
password=" , ".join( map(str, i) ) #transition list to string
67
+
68
+
k_encode=k.encode() #encode key to byte
69
+
p_encode=password.encode() #encode password to byte
0 commit comments