Add method exists.

master
voussoir 2022-07-10 15:19:01 -07:00
parent 18de52ecb7
commit 3dd270bb4a
No known key found for this signature in database
GPG Key ID: 5F7554F8C26DACCB
1 changed files with 9 additions and 0 deletions

View File

@ -197,6 +197,15 @@ class Database(metaclass=abc.ABCMeta):
log.loud(line) log.loud(line)
cur.execute(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): def get_object_by_id(self, object_class, object_id):
''' '''
Select an object by its ID. Select an object by its ID.