def getTriggerDBCursor(connection): connectionParameters = interpretConnection(connection) technology = connectionParameters["techno"] if technology == 'sqlite': cursor = _get_sqlite_cursor(connectionParameters["filename"]) schema = '' elif technology == 'oracle': cursor = _get_oracle_cursor(connectionParameters["server"], connectionParameters["user"], connectionParameters["passwd"]) schema = connectionParameters["schema"].rstrip('.') + '.' elif technology == 'frontier': from TrigConfigSvc.TrigConfFrontier import getFrontierCursor cursor = getFrontierCursor( connectionParameters["url"], connectionParameters["schema"], logging.getLogger("TrigConfigSvcUtils.py").level) schema = connectionParameters["schema"].rstrip('.') + '.' elif technology == 'mysql': cursor = _get_mysql_cursor(connectionParameters["server"], connectionParameters["dbname"], connectionParameters["user"], connectionParameters["passwd"]), '' schema = '' return cursor, schema
def getTriggerDBCursor(run_number = None, smk = None, isRun2 = None): index = 1 if isTriggerRun2(run_number = run_number, smk = smk, isRun2 = isRun2 ) else 0 global __cursor_schema if __cursor_schema[index][0]: return __cursor_schema[index] # return the correct cursor and schema name # need to connect connection = triggerDBAlias(run_number = run_number, smk = smk, isRun2 = isRun2) connectionParameters = interpretConnection(connection) technology = connectionParameters["techno"] if technology == 'sqlite': cursor = _get_sqlite_cursor(connectionParameters["filename"]) schema = '' elif technology == 'oracle': cursor = _get_oracle_cursor(connectionParameters["server"], connectionParameters["user"], connectionParameters["passwd"]) schema = connectionParameters["schema"].rstrip('.') + '.' elif technology == 'frontier': from TrigConfigSvc.TrigConfFrontier import getFrontierCursor cursor = getFrontierCursor(connectionParameters["url"], connectionParameters["schema"], logging.getLogger("TrigConfigSvcUtils.py").level) schema = connectionParameters["schema"].rstrip('.') + '.' elif technology == 'mysql': cursor = _get_mysql_cursor(connectionParameters["server"], connectionParameters["dbname"], connectionParameters["user"], connectionParameters["passwd"]),'' schema = '' __cursor_schema[index] = (cursor,schema) return __cursor_schema[index] # return the correct cursor and schema name
def connect_to_oracle_via_frontier(self,frontier_server,schema,directory=""): "Connect to Oracle via Frontier" from TrigConfigSvc.TrigConfFrontier import getFrontierCursor self.cursor = getFrontierCursor(frontier_server,schema) self.directory = directory if self.directory != "": self.directory = self.directory+"."