From 50bd3d6170699a42fea25cc2d3339b280a65f597 Mon Sep 17 00:00:00 2001 From: relikd Date: Tue, 21 Feb 2023 15:43:37 +0100 Subject: [PATCH] fix: query only contacts with ABCDContact type --- ABCDDB.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/ABCDDB.py b/ABCDDB.py index df6c88b..f3be6a8 100755 --- a/ABCDDB.py +++ b/ABCDDB.py @@ -251,6 +251,11 @@ class Service(Queryable): class Record: @staticmethod def queryAll(cursor: sqlite3.Cursor) -> Dict[int, 'Record']: + # get z_ent id that is used for contact cards + z_ent = cursor.execute( + 'SELECT Z_ENT FROM Z_PRIMARYKEY WHERE Z_NAME == "ABCDContact"' + ).fetchone()[0] + # find all records that match this id return {x[0]: Record(x) for x in cursor.execute(''' SELECT Z_PK, ZFIRSTNAME, ZLASTNAME, ZMIDDLENAME, ZTITLE, ZSUFFIX, @@ -260,7 +265,7 @@ class Record: strftime('%Y-%m-%d', ZBIRTHDAY + 978307200, 'unixepoch'), ZTHUMBNAILIMAGEDATA, ZDISPLAYFLAGS FROM ZABCDRECORD - WHERE ZCONTAINER1 IS NOT NULL;''')} + WHERE Z_ENT = ?;''', [z_ent])} def __init__(self, row: List[Any]) -> None: self.id = row[0] # type: int