You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: examples/official-site/sqlpage/migrations/01_documentation.sql
+28-4Lines changed: 28 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -810,14 +810,38 @@ INSERT INTO parameter(component, name, description, type, top_level, optional) S
810
810
('separator', 'How individual values should be separated in the CSV. "," by default, set it to "\t" for tab-separated values.', 'TEXT', TRUE, TRUE),
811
811
('title', 'The text displayed on the download button.', 'TEXT', TRUE, FALSE),
812
812
('filename', 'The name of the file that should be downloaded (without the extension).', 'TEXT', TRUE, TRUE),
813
-
('icon', 'Name of the icon (from tabler-icons.io) to display in the button.', 'ICON', TRUE, TRUE),
814
-
('color', 'Color of the button', 'COLOR', TRUE, TRUE),
815
-
('size', 'The size of the button (e.g., sm, lg).', 'TEXT', TRUE, TRUE),
813
+
('icon', 'Name of the icon (from tabler-icons.io) to display in the button. Ignored when used as a header component.', 'ICON', TRUE, TRUE),
814
+
('color', 'Color of the button. Ignored when used as a header component.', 'COLOR', TRUE, TRUE),
815
+
('size', 'The size of the button (e.g., sm, lg). Ignored when used as a header component.', 'TEXT', TRUE, TRUE),
816
816
('bom', 'Whether to include a Byte Order Mark (a special character indicating the character encoding) at the beginning of the file. This is useful for Excel compatibility.', 'BOOLEAN', TRUE, TRUE)
817
817
) x;
818
818
819
819
INSERT INTO example(component, description, properties) VALUES
820
-
('csv', 'CSV download button',
820
+
('csv', '
821
+
### Header component: creating a CSV download URL
822
+
823
+
You can create a page that will trigger a download of the CSV file when the user visits it.
824
+
The contents will be streamed efficiently from the database to the browser, without being fully loaded in memory.
825
+
This makes it possible to download even very large files without overloading the database server, the web server, or the client''s browser.
826
+
827
+
#### `csv_download.sql`
828
+
829
+
```sql
830
+
select ''csv'' as component, ''example.csv'' as filename;
831
+
SELECT * FROM my_large_table;
832
+
```
833
+
834
+
#### `index.sql`
835
+
',
836
+
json('[{"component":"button"}, {"title": "Download my data", "link": "/examples/csv_download.sql"}]')),
837
+
('csv', '
838
+
### CSV download button
839
+
840
+
This will generate a button to download the CSV file.
841
+
The button element itself will embed the entire contents of the CSV file, so it should not be used for large files.
842
+
The file will be entirely loaded in memory on the user''s browser, even if the user does not click on the button.
843
+
For smaller files, this is easier and faster to use than creating a separate SQL file to generate the CSV.
0 commit comments