From 200ed14d13a99c72f090ef0a7e58fb6b441e013a Mon Sep 17 00:00:00 2001 From: David Todd Date: Sat, 18 Jan 2020 21:38:33 -0600 Subject: [PATCH] Move Database into API, minor tweaks --- {db => api/db}/__init__.py | 0 {db => api/db}/db.py | 8 ++++++-- 2 files changed, 6 insertions(+), 2 deletions(-) rename {db => api/db}/__init__.py (100%) rename {db => api/db}/db.py (97%) diff --git a/db/__init__.py b/api/db/__init__.py similarity index 100% rename from db/__init__.py rename to api/db/__init__.py diff --git a/db/db.py b/api/db/db.py similarity index 97% rename from db/db.py rename to api/db/db.py index 5273305..27bd771 100644 --- a/db/db.py +++ b/api/db/db.py @@ -95,13 +95,13 @@ class Database: exist in the database adding a new entry if that is the case. If the `uri` is already stored (based on the generated UUID), the existing - entry will be returned instead. + entry's UUID will be returned instead. """ uri_uuid = uuid.uuid5(uuid.NAMESPACE_URL, uri) bookmark_exists = self.get_bookmark(uri_uuid) if bookmark_exists != None: - return bookmark_exists + return bookmark_exists[0] query = """ INSERT INTO bookmarks ( @@ -125,6 +125,10 @@ class Database: query = "DELETE FROM bookmarks WHERE bookmark_id = ?" self.cursor.execute(query, (bookmark_id, )) + if self.get_bookmark(bookmark_id) == None: + return True + return False + def update_bookmark_title(self, bookmark_id, new_title): """ Takes the provided `bookmark_id`, searches the