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

19
buku
View File

@ -163,14 +163,19 @@ 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.")
# Create a connection
conn = sqlite3.connect(dbfile)
cur = conn.cursor()
try:
# Create a connection
conn = sqlite3.connect(dbfile)
cur = conn.cursor()
# Create table if it doesn't exist
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)
# Create table if it doesn't exist
cur.execute('''CREATE TABLE if not exists bookmarks \
(id integer PRIMARY KEY, URL text NOT NULL UNIQUE, metadata text, tags text)''')
conn.commit()
return (conn, cur)