aboutsummaryrefslogtreecommitdiffstats
path: root/database.py
diff options
context:
space:
mode:
authorjwansek <eddie.atten.ea29@gmail.com>2021-03-06 21:51:06 +0000
committerjwansek <eddie.atten.ea29@gmail.com>2021-03-06 21:51:06 +0000
commit2a0d3c4ccb287282974856b5f20f67a078149cb8 (patch)
tree604f111e1445dfed221507522584ee0f6fcdae32 /database.py
parentdd073f7256bd53162e1ee93c6777ba6c7e97f3ca (diff)
downloadeda.gay-2a0d3c4ccb287282974856b5f20f67a078149cb8.tar.gz
eda.gay-2a0d3c4ccb287282974856b5f20f67a078149cb8.zip
added dockerfile, similar thoughts
Diffstat (limited to 'database.py')
-rw-r--r--database.py14
1 files changed, 10 insertions, 4 deletions
diff --git a/database.py b/database.py
index 06dc34d..bb870b8 100644
--- a/database.py
+++ b/database.py
@@ -91,6 +91,15 @@ class Database:
WHERE thought_id = %s;""", (id_, ))
return cursor.fetchone()
+ def get_similar_thoughts(self, category, id_):
+ with self.__connection.cursor() as cursor:
+ cursor.execute("""
+ SELECT thought_id, title, dt, category_name FROM thoughts
+ INNER JOIN categories ON thoughts.category_id = categories.category_id
+ WHERE category_name = %s AND thought_id != %s;""",
+ (category, id_))
+ return cursor.fetchall()
+
def get_featured_thoughts(self):
with self.__connection.cursor() as cursor:
cursor.execute("SELECT thought_id, title FROM thoughts WHERE featured = 1;")
@@ -223,8 +232,5 @@ def request_recent_commits(since = datetime.datetime.now() - datetime.timedelta(
return sorted(out, key = lambda a: a["datetime"], reverse = True)
if __name__ == "__main__":
- import datetime
- start = datetime.datetime.now()
with Database() as db:
- print(db.get_cached_tweets())
- print("Took: ", (datetime.datetime.now() - start)) \ No newline at end of file
+ print(db.get_similar_thoughts("about me", 5)) \ No newline at end of file