Skip to content

Ability to return html string directly and avoid opening browser locally #2

Description

@mskyttner

Thanks for a great extension, very useful!

I would love the ability to get the html string directly.

The steps for writing the html string to disk and launching browser are difficult to skip currently.

Rationale: When using the extension on headless servers it may not have a browser available, so a way to avoid the launching of the browser would be great. Also ability to write the html string directly for example to stdout via COPY (...) TO '/dev/stdout'; allows for usage with pipes.

Current workaround, which picks up the returned path to the generated file from the return value and reads the html back and stores the chart it in a table:

load miniplot;

set variable my_chart = (
    select regexp_extract(bar_chart(
        ['Q1', 'Q2', 'Q3', 'Q4'],
        [100.0, 150.0, 200.0, 180.0],
        'Quarterly Sales'
    ) , 'opened: (.*?mp/.*?)$', 1)
);

create or replace table my_charts as (
    from read_text(getvariable('my_chart')) 
    select 
        title: 'Quarterly Sales',
        html: content,
        file: getvariable('my_chart'),
);

from my_charts select html limit 1;

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions