def load_SQL_database(self): table_columns = [ "ResultID", "FeatureCode", "Variable", "Unit", "Type", "Organization", "Date Created" ] self.table.set_columns(table_columns) db = self.get_selected_database() if not len(db): return if db["args"]["engine"] == "sqlite": session_factory = dbconnection2.createConnection( engine=db["args"]["engine"], address=db["args"]["address"]) session = db2.connect(session_factory) series = session.getAllSeries() elif db["args"]["engine"] == "postgresql": # db is postresql session_factory = dbUtilities.build_session_from_connection_string( db["connection_string"]) session = db2.connect(session_factory) series = session.getAllSeries() else: # Fails if db is not sqlite or postresql raise Exception("Failed to load database") if not series: self.table.empty_list_message.Show() return self.table.empty_list_message.Hide() data = self.series_to_table_data(series) self.table.set_table_content(data)
def load_SQL_database(self): table_columns = ["ResultID", "FeatureCode", "Variable", "Unit", "Type", "Organization", "Date Created"] self.table.set_columns(table_columns) db = self.get_selected_database() if not len(db): return if db["args"]["engine"] == "sqlite": session_factory = dbconnection2.createConnection(engine=db["args"]["engine"], address=db["args"]["address"]) session = db2.connect(session_factory) series = session.getAllSeries() elif db["args"]["engine"] == "postgresql": # db is postresql session_factory = dbUtilities.build_session_from_connection_string(db["connection_string"]) session = db2.connect(session_factory) series = session.getAllSeries() else: # Fails if db is not sqlite or postresql raise Exception("Failed to load database") if not series: self.table.empty_list_message.Show() return self.table.empty_list_message.Hide() data = self.series_to_table_data(series) self.table.set_table_content(data)
def get_current_database_session(self, dbName=None): if dbName is not None: dbs = engine.getDbConnections() for db in dbs.iterkeys(): if dbs[db]['name'] == dbName: self._currentDbSession = dbUtilities.build_session_from_connection_string( dbs[db]['connection_string']) break return self._currentDbSession
def get_database_session(self): """ Connect to the respective database and return the session Exception is raised if it is not a sqlite or postresql :return: """ db = self.get_selected_database() if db["args"]['engine'] == "sqlite": session_factory = dbconnection.createConnection(engine=db["args"]["engine"], address=db["args"]["address"], db=db["args"]["db"], user=db["args"]["user"], password=db["args"]["pwd"]) session = db2.connect(session_factory) return session elif db["args"]["engine"] == "postgresql": session_factory = dbUtilities.build_session_from_connection_string(db['connection_string']) session = db2.connect(session_factory) return session else: raise Exception("Failed to load simulations database")
def get_database_session(self): """ Connect to the respective database and return the session Exception is raised if it is not a sqlite or postresql :return: """ db = self.get_selected_database() if db["args"]['engine'] == "sqlite": session_factory = dbconnection.createConnection( engine=db["args"]["engine"], address=db["args"]["address"], db=db["args"]["db"], user=db["args"]["user"], password=db["args"]["pwd"]) session = db2.connect(session_factory) return session elif db["args"]["engine"] == "postgresql": session_factory = dbUtilities.build_session_from_connection_string( db['connection_string']) session = db2.connect(session_factory) return session else: raise Exception("Failed to load simulations database")