예제 #1
0
def edit(client, query_id, query, execute):
    if not query_id:
        query_id = client.get("queries/my", limit=1)[0].get("id")
    if not query:
        initial_query = client.get(f"queries/{query_id}").get("query")
        query = click.edit(text=initial_query, extension=".sql")
    response = client.post(f"queries/{query_id}", dict(query=query))
    if execute:
        utils.echo(perform_download(client, query_id))
    else:
        utils.echo(response)
예제 #2
0
파일: new.py 프로젝트: jmsanders/redash-cli
def new(client, query, data_source_id, name, execute):
    if not data_source_id:
        data_source_id = client.config.data_source_id
    if not query:
        query = click.edit(extension=".sql")
    response = client.post(
        "queries", dict(query=query, data_source_id=data_source_id, name=name))
    query_id = response.get("id")
    if execute:
        utils.echo(perform_download(client, query_id))
    else:
        utils.echo(response)
예제 #3
0
def queries(client, limit, mine):
    endpoint = "queries/my" if mine else "queries"
    utils.echo(client.get(endpoint, limit=limit))
예제 #4
0
def data_sources(client):
    utils.echo(client.get("data_sources"))
예제 #5
0
def download(client, query_id):
    if not query_id:
        query_id = client.get("queries/my", limit=1)[0].get("id")
    utils.echo(perform_download(client, query_id))