Nested try/except fix

This commit is contained in:
SimpleArt
2020-11-21 21:36:07 -05:00
parent bd9016a297
commit d8974ddb1c

View File

@ -257,36 +257,34 @@ class SQL_Database:
# Getters and setter for class # Getters and setter for class
def get_config_id(self): def get_config_id(self):
try: try:
# return the config id if its already set # return the config id if its already set
self.__config_id = "something" self.config_id = "something"
except:
# Get the most resent run from config table.
pass
except: except:
# config_id and config table dont exist: Tell the user # config_id and config table dont exist: Tell the user
print("""You are required to run a ga before you print("""You are required to run a ga before you
can connect to the database. Run ga.evolve()""") can connect to the database. Run ga.evolve()""")
break
def get_conn(self): def get_conn(self):
"""Conn """ """Conn """
try: try:
# Return if the connection has already been set # Return if the connection has already been set
return self.__conn return self.conn
except:
# Check if you can connect to the database named in ga
self.__conn = self.create_connection(ga.database_name)
except: except:
# See if the default database exists
self.__conn = self.create_connection("database.db") try:
# Check if you can connect to the database named in ga
self.conn = self.create_connection(ga.database_name)
return self.conn
except: except:
# if the connection # if the connection
print("""You are required to run a ga before you print("""You are required to run a ga before you
can connect to the database. Run ga.evolve()""") can connect to the database. Run ga.evolve()""")
break return