From 3dd270bb4a593d89c4a62466d636bd0db241e612 Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Sun, 10 Jul 2022 15:19:01 -0700 Subject: [PATCH] Add method exists. --- voussoirkit/worms.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/voussoirkit/worms.py b/voussoirkit/worms.py index aa152e5..ffb2330 100644 --- a/voussoirkit/worms.py +++ b/voussoirkit/worms.py @@ -197,6 +197,15 @@ class Database(metaclass=abc.ABCMeta): log.loud(line) cur.execute(line) + def exists(self, query, bindings=None) -> bool: + ''' + query should be a SELECT query. + + Returns True if at least one row was found, False if no rows found. + ''' + row = self.select_one(query, bindings) + return (row is not None) + def get_object_by_id(self, object_class, object_id): ''' Select an object by its ID.