StarsDB: add close function
This commit is contained in:
@@ -26,6 +26,7 @@ class StarDB():
|
||||
if(dbName in StarDB.__dbNames):
|
||||
raise Exception(f"StarDB {dbName} cannot be instantiated more than once!")
|
||||
else:
|
||||
self.dbName = dbName
|
||||
StarDB.__dbNames.append(dbName)
|
||||
StarDB.__instances.append(self)
|
||||
|
||||
@@ -42,6 +43,11 @@ class StarDB():
|
||||
else:
|
||||
self.initializeDB()
|
||||
|
||||
def close(self):
|
||||
StarDB.__instances.remove(self)
|
||||
StarDB.__dbNames.remove(self.dbName)
|
||||
self.connection.close()
|
||||
|
||||
def initializeDB(self):
|
||||
print("Initializing database")
|
||||
self.dbCursor.execute("""CREATE TABLE IF NOT EXISTS starnames
|
||||
|
||||
Reference in New Issue
Block a user