-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
109 lines (78 loc) · 3.05 KB
/
Copy pathmain.py
File metadata and controls
109 lines (78 loc) · 3.05 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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# Semi working main.py, love from Koishi Komeiji
from lib.sqlitelib import local
from lib.migratedb import migrate
from dotenv import load_dotenv
from lib.libraries import SqlServer
import os
_ = load_dotenv()
sql_type = os.getenv("DB_SERVER", "sqlite")
print("Using Server:", sql_type, "\n")
if sql_type == "sqlite" or sql_type == "local":
sql= local()
else:
sql = SqlServer()
def main() -> None:
while True:
print("1. input")
print("2. Delete")
print("3. Edit")
print("4. Search")
print("5. Showall")
print("6. Migrate")
print("7. exit")
choice = input("Enter your choice: ")
if choice == '1':
print("inserting..\n")
terminater = True
while terminater:
username = input("enter username/email\n>>")
website = input("enter website\n>>")
password = input("enter password\n>>")
comment_note = input("comments\n>>")
sql.insert(username=username, password=password, website=website, comment=comment_note) # pyright: ignore[reportCallIssue]
sql.results(username, password, website)
x = str(input("success.. you want to enter again(y/n)?"))
if x.upper() == "Y":
continue
else:
terminater = False
elif choice == '2':
print("Delete entry row using unique id. warining: This is dangerous and there's no undo button...\n")
Terminator = True
while Terminator:
print("\nList of all passwords:")
sql.showall()
try:
id = int(input("Enter a row id to delete(type nothing to exit)\n>>"))
sql.delete(id)
except Exception:
print("exiting...")
x = input("want to delete another entry?")
if x.upper() == 'Y':
Terminator = True
else:
Terminator = False
elif choice == '3':
sql.showall()
id = int(input("\nChoose the id to edit\n>>"))
print("\ninput. Enter provided fields. leave blank so it will not change\n")
username = input("enter username/email\n>>")
website = input("enter website\n>>")
password = input("enter password\n>>")
comment = input("comments\n>>")
sql.edit(id=id, username=username, password=password, website=website, comment=comment) # pyright: ignore[reportCallIssue]
elif choice == '4':
print("Search saved password using a website\n")
query = input("search query\n>>")
sql.search(search=query)
elif choice == '5':
sql.showall()
elif choice == '6':
migrate()
elif choice == '7':
print("Exiting...")
break
else:
print("Invalid choice. Please try again.")
if __name__ == "__main__":
main()