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)
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)
def queries(client, limit, mine): endpoint = "queries/my" if mine else "queries" utils.echo(client.get(endpoint, limit=limit))
def data_sources(client): utils.echo(client.get("data_sources"))
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))