import
webbrowser
import
sqlite3
conn
=
sqlite3.connect(
"favorites.db"
)
c
=
conn.cursor()
c.execute(
)
def
get_data():
c.execute(
)
results
=
c.fetchall()
return
results
def
get_fav(titl):
c.execute(
,
(titl, ))
return
c.fetchone()
def
add_fav(titl, url):
c.execute(
,
(titl, url))
conn.commit()
def
remove_fav(titl):
c.execute(
,
(titl, ))
conn.commit()
while
True
:
print
()
print
(
"Press v to visit a favorite,"
, end
=
" "
)
print
(
"ls for list,"
, end
=
" "
)
print
(
"add to add a new item,"
, end
=
" "
)
print
(
"rm to delete,"
, end
=
" "
)
print
(
"q to quit:"
, end
=
" "
)
response
=
input
("")
if
response.lower()
=
=
"v"
:
shortcut
=
input
(
"Enter the shortcut for the website: "
)
record
=
get_fav(shortcut)
try
:
webbrowser.
open
(record[
1
])
except
TypeError:
print
(
'This shortcut does not exist in the database'
)
elif
response.lower()
=
=
"ls"
:
print
(get_data())
elif
response.lower()
=
=
"add"
:
destination
=
input
(
shortcut
=
input
(
"Enter the shortcut for the URL: "
)
add_fav(shortcut, destination)
elif
response.lower()
=
=
"rm"
:
shortcut
=
input
(
"Enter the shortcut for the URL you want to remove: "
)
remove_fav(shortcut)
print
(
"Removed Successfully"
)
elif
response.lower()
=
=
"q"
:
break
else
:
print
(
"Enter a valid command"
)