Catch exception if DB file encrypted or not SQLite.

This commit is contained in:
Arun Prakash Jana 2016-05-07 21:26:20 +05:30
parent 7eee768e18
commit 1f83c66fa5
No known key found for this signature in database
GPG Key ID: C0A712ED95043DCB

5
buku
View File

@ -163,6 +163,7 @@ def initdb():
if no_crypto == False and not os.path.exists(dbfile):
print("DB file is being created. You may want to encrypt it later.")
try:
# Create a connection
conn = sqlite3.connect(dbfile)
cur = conn.cursor()
@ -171,6 +172,10 @@ def initdb():
cur.execute('''CREATE TABLE if not exists bookmarks \
(id integer PRIMARY KEY, URL text NOT NULL UNIQUE, metadata text, tags text)''')
conn.commit()
except Exception as e:
print("\x1b[1mEXCEPTION\x1b[21m [initdb]: (%s) %s" % (type(e).__name__, e))
sys.exit(1)
return (conn, cur)