Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Commit 46f4edf

Browse files
committed
webui: Add support for exporting query result in execute page to CSV
This adds a button to export the results of SELECT queries to a CSV file in the execute page.
1 parent cd967c2 commit 46f4edf

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

webui/jsx/sql-terminal.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import {highlight, languages} from "prismjs/components/prism-core";
88
import "prismjs/components/prism-sql";
99
import "prismjs/themes/prism-solarizedlight.css";
1010
import {format} from "sql-formatter";
11+
import { convertResultsetToCsv, downloadData } from "./export-data";
1112

1213
/********************
1314
* The general structure here is this:
@@ -45,7 +46,10 @@ function SqlTerminalCommandOutput({state, data}) {
4546
output = <span className="text-info"><strong>done: </strong>{data.rows_changed + " row" + (data.rows_changed === 1 ? "" : "s") + " changed"}</span>;
4647
} else if (state === "queried") {
4748
output = (<>
48-
<span className="text-info"><strong>done: </strong>{data.RowCount + " row" + (data.RowCount === 1 ? "" : "s") + " returned"}</span>
49+
<span className="text-info">
50+
<strong>done: </strong>{data.RowCount + " row" + (data.RowCount === 1 ? "" : "s") + " returned"}&nbsp;
51+
<a href="#/" title="Export results to CSV" onClick={() => downloadData(convertResultsetToCsv(data), "result.csv", "text/csv")}><i className={"fa fa-download"}></i></a>
52+
</span>
4953
<div className="table-responsive">
5054
<table className="table table-hover table-condensed">
5155
<thead>

0 commit comments

Comments
 (0)