Confirm DB cleansing.

Signed-off-by: Arun Prakash Jana <engineerarun@gmail.com>
This commit is contained in:
Arun Prakash Jana 2016-03-20 09:48:13 +05:30
parent a75a56cd5a
commit 366b493ca0

6
buku
View File

@ -344,8 +344,14 @@ def searchdb(cur, keywords):
# Delete a single record or remove the table
def cleardb(conn, cur, index):
if index == None: # Remove the table
resp = input("ALL bookmarks will be removed. Enter \x1b[1my\x1b[21m to confirm: ")
if resp != 'y':
print("No bookmarks deleted")
return
cur.execute('DROP TABLE if exists bookmarks')
conn.commit()
print("All bookmarks deleted")
else: # Remove a single entry
try:
cur.execute("DELETE FROM bookmarks WHERE id = ?", (int(index),))