Example #1
0
    def start_workers(self, workers_count, connection_type, connection_string):
        if self.workers:
            return self.workers
        
        if connection_type == 'mysql':
            from redash.data import query_runner_mysql
            runner = query_runner_mysql.mysql(connection_string)
        elif connection_type == 'graphite':
            from redash.data import query_runner_graphite
            connection_params = json.loads(connection_string)
            if connection_params['auth']:
                connection_params['auth'] = tuple(connection_params['auth'])
            else:
                connection_params['auth'] = None
            runner = query_runner_graphite.graphite(connection_params)
        else:
            from redash.data import query_runner
            runner = query_runner.redshift(connection_string)

        redis_connection_params = self.redis_connection.connection_pool.connection_kwargs
        self.workers = [worker.Worker(self, redis_connection_params, runner)
                        for _ in range(workers_count)]
        for w in self.workers:
            w.start()

        return self.workers
Example #2
0
def get_query_runner(connection_type, connection_string):
    if connection_type == 'mysql':
        from redash.data import query_runner_mysql
        runner = query_runner_mysql.mysql(connection_string)
    elif connection_type == 'graphite':
        from redash.data import query_runner_graphite
        connection_params = json.loads(connection_string)
        if connection_params['auth']:
            connection_params['auth'] = tuple(connection_params['auth'])
        else:
            connection_params['auth'] = None
        runner = query_runner_graphite.graphite(connection_params)
    elif connection_type == 'bigquery':
        from redash.data import query_runner_bigquery
        connection_params = json.loads(connection_string)
        runner = query_runner_bigquery.bigquery(connection_params)
    elif connection_type == 'script':
        from redash.data import query_runner_script
        runner = query_runner_script.script(connection_string)
    elif connection_type == 'url':
        from redash.data import query_runner_url
        runner = query_runner_url.url(connection_string)
    elif connection_type == "mongo":
        from redash.data import query_runner_mongodb
        connection_params = json.loads(connection_string)
        runner = query_runner_mongodb.mongodb(connection_params)
    else:
        from redash.data import query_runner_pg
        runner = query_runner_pg.pg(connection_string)

    return runner
Example #3
0
    def start_workers(self, workers_count, connection_type, connection_string):
        if self.workers:
            return self.workers

        if connection_type == "mysql":
            from redash.data import query_runner_mysql

            runner = query_runner_mysql.mysql(connection_string)
        elif connection_type == "graphite":
            from redash.data import query_runner_graphite

            runner = query_runner_graphite.graphite(connection_string)
        else:
            from redash.data import query_runner

            runner = query_runner.redshift(connection_string)

        redis_connection_params = self.redis_connection.connection_pool.connection_kwargs
        self.workers = [worker.Worker(self, redis_connection_params, runner) for _ in range(workers_count)]
        for w in self.workers:
            w.start()

        return self.workers