diff --git a/astrodatagui/db/StarsDB.py b/astrodatagui/db/StarsDB.py new file mode 100644 index 0000000..5dcfb66 --- /dev/null +++ b/astrodatagui/db/StarsDB.py @@ -0,0 +1,40 @@ +from enum import Enum +import sqlite3 + +class StarDBError(Enum): + NO_ERROR = 0 + DB_CONNECTION_FAILED = 1 + +DB_NAME = "stars.db" + +class StarDB(): + __instanceVar = None + + @staticmethod + def getInstance(): + if(StarDB.__instanceVar == None): + return StarDB() + else: + return StarDB.__instanceVar + + def __init__(self): + if(StarDB.__instanceVar != None): + raise Exception("StarDB cannot be instantiated more than once!") + else: + StarDB.__instanceVar = self + + self.error = StarDBError.NO_ERROR + + try: + con = sqlite3.connect(DB_NAME) + self.dbCursor = con.cursor() + except: + self.error = StarDBError.DB_CONNECTION_FAILED + + if(self.error is not StarDBError.NO_ERROR): + raise Exception("StarDB cannot connect to the database!") + else: + self.initializeDB() + + def initializeDB(self): + return \ No newline at end of file diff --git a/astrodatagui/db/__init__.py b/astrodatagui/db/__init__.py new file mode 100644 index 0000000..e69de29