astrodatagui: StarsDB: add table for additional star info

This commit is contained in:
2024-03-11 14:43:09 +01:00
parent 0e3aec7097
commit e3a7bb3a45
+32 -2
View File
@@ -75,6 +75,18 @@ class StarDB():
FOREIGN KEY (sourceName) REFERENCES sequenceSourceNames(sourceName) FOREIGN KEY (sourceName) REFERENCES sequenceSourceNames(sourceName)
);""") );""")
self.dbCursor.execute("""CREATE TABLE IF NOT EXISTS starInfo
(
mainName TEXT,
spType TEXT,
rotVel REAL,
rotVelUnit TEXT,
dist REAL,
distUnit TEXT,
PRIMARY KEY (mainName),
FOREIGN KEY (mainName) REFERENCES starnames(mainName)
);""")
self.insertDefaultValues() self.insertDefaultValues()
self.connection.commit() self.connection.commit()
@@ -92,8 +104,20 @@ class StarDB():
starnames(mainName, altName) starnames(mainName, altName)
VALUES(\"{mainName}\", \"{an["ID"]}\")""") VALUES(\"{mainName}\", \"{an["ID"]}\")""")
def insertStar(self, mainName: str, altNames, productManifest): def insertStarInformations(self, mainName, spType, rotVel, rotVelUnit,
dist, distUnit):
print(f"""INSERT OR IGNORE INTO
starInfo(mainName, spType, rotVel, rotVelUnit, dist, distUnit)
VALUES(\"{mainName}\", \"{spType}\", {rotVel}, \"{rotVelUnit}\", {dist}, \"{distUnit}\")""")
self.dbCursor.execute(f"""INSERT OR IGNORE INTO
starInfo(mainName, spType, rotVel, rotVelUnit, dist, distUnit)
VALUES(\"{mainName}\", \"{spType}\", {rotVel}, \"{rotVelUnit}\", {dist}, \"{distUnit}\")""")
def insertStar(self, mainName: str, altNames, productManifest,
spType, rotVel, rotVelUnit, dist, distUnit):
self.insertStarAlternativeNames(mainName, altNames) self.insertStarAlternativeNames(mainName, altNames)
self.insertStarInformations(mainName, spType, rotVel, rotVelUnit,
dist, distUnit)
for pm in productManifest: for pm in productManifest:
file = pm["Local Path"] file = pm["Local Path"]
source = pm["source"] source = pm["source"]
@@ -110,7 +134,7 @@ class StarDB():
ORDER BY mainName""") ORDER BY mainName""")
return res.fetchall() return res.fetchall()
def getStarData(self, mainName): def getStarSequences(self, mainName):
res = self.dbCursor.execute(f"""SELECT sourceName, sequence FROM stars res = self.dbCursor.execute(f"""SELECT sourceName, sequence FROM stars
WHERE mainName = \"{mainName}\" WHERE mainName = \"{mainName}\"
ORDER BY ORDER BY
@@ -118,6 +142,12 @@ class StarDB():
sequence ASC""") sequence ASC""")
return res.fetchall() return res.fetchall()
def getStarInfos(self, mainName):
res = self.dbCursor.execute(f"""SELECT spType, rotVel, rotVelUnit, dist, distUnit
FROM starInfo
WHERE mainName = \"{mainName}\"""")
return res.fetchone()
def getFilePath(self, mainName, source, sequence): def getFilePath(self, mainName, source, sequence):
print(f"Trying for {mainName}, {source}, {sequence}") print(f"Trying for {mainName}, {source}, {sequence}")
res = self.dbCursor.execute(f"""SELECT filename FROM stars res = self.dbCursor.execute(f"""SELECT filename FROM stars