Catch exception if DB file encrypted or not SQLite.
This commit is contained in:
parent
7eee768e18
commit
1f83c66fa5
19
buku
19
buku
@ -163,14 +163,19 @@ def initdb():
|
|||||||
if no_crypto == False and not os.path.exists(dbfile):
|
if no_crypto == False and not os.path.exists(dbfile):
|
||||||
print("DB file is being created. You may want to encrypt it later.")
|
print("DB file is being created. You may want to encrypt it later.")
|
||||||
|
|
||||||
# Create a connection
|
try:
|
||||||
conn = sqlite3.connect(dbfile)
|
# Create a connection
|
||||||
cur = conn.cursor()
|
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)
|
return (conn, cur)
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user