From f84a61f02837d4ae8209c63d2941adc042a91018 Mon Sep 17 00:00:00 2001 From: SGCMarkus Date: Fri, 8 Mar 2024 11:48:00 +0100 Subject: [PATCH] astrodatagui: StarsDB: add functions to read inserted information --- main/astrodatagui/db/StarsDB.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/main/astrodatagui/db/StarsDB.py b/main/astrodatagui/db/StarsDB.py index 28b577d..9405d30 100644 --- a/main/astrodatagui/db/StarsDB.py +++ b/main/astrodatagui/db/StarsDB.py @@ -104,3 +104,26 @@ class StarDB(): VALUES(\"{mainName}\", \"{source}\", {sequence}, \"{file}\")""") self.connection.commit() + + def getAllStars(self): + res = self.dbCursor.execute("""SELECT DISTINCT mainName FROM stars + ORDER BY mainName""") + return res.fetchall() + + def getStarData(self, mainName): + res = self.dbCursor.execute(f"""SELECT sourceName, sequence FROM stars + WHERE mainName = \"{mainName}\" + ORDER BY + sourceName ASC, + sequence ASC""") + return res.fetchall() + + def getFilePath(self, mainName, source, sequence): + print(f"Trying for {mainName}, {source}, {sequence}") + res = self.dbCursor.execute(f"""SELECT filename FROM stars + WHERE + mainName = \"{mainName}\" AND + sourceName = \"{source}\" AND + sequence = {sequence} + """) + return res.fetchone()[0]