Hello, i'm very impressed with duckd and his ecosystem. UI extension is very interesting and i already export the notebook in XLSX files to share my process and transmit it. As a future improvement, will it be possible to have two types of export directly from the UI: - each cell into a single SQL file? - all cells into a single SQL file? In the same idea, it will be very interesting importing SQL file in UI and generate cells foreach request. A bit like the Marimo notebooks in Python. Thank you
Howdy Ezio! If you are using the DuckDB UI extension, you have another option already available to you! The DuckDB UI actually stores all of the state of the notebook (including the SQL in every cell) in a local DuckDB file. So, you could use the DuckDB UI to query that data and export it in whatever format you'd like! The excel community extension for DuckDB would work for exporting to xlsx as well. That DuckDB database is stored here: ~/.duckdb/extension_data/ui/ui.db
I understand and i saw your documentation about snippets. If i remember correctly. It's works very well, nice greate. I think it will very interesting for users who begin to use SQL from DuckDB Notebook to have this feature from cell, from notebook. It will contribute to increase audiance to use DuckDB before others python stack. If we can trigger this two function from web button it will be very user friendly . It's just that I thought it was a shame that while you can export the results of an SQL query as JSON, Parquet, CSV, or TSV, you can't export the notebook from the web interface. Maybe it become in the next pull-request.... ;o)
-- ALL NOTEBOOK
PREPARE export_duckbook AS
COPY (
SELECT
json_extract_string("json"->'cells','$[*].query')
.array_to_string(E'\n\n')
.encode()
FROM _duckdb_ui.notebook_versions
WHERE title=$title_notebook AND expires IS NULL)
TO $file_with_extension (FORMAT $format_file);
EXECUTE export_duckbook(title_notebook:='ExampleNotebook',file_with_extension:='duckbook.sql',format_file:='BLOB');
-- ONE CELL SELECTED
PREPARE export_duckcell AS
COPY (
SELECT
(json_extract_string("json"->'cells','$[*].query')[$duckcell_number::int]).encode()
FROM _duckdb_ui.notebook_versions
WHERE title=$title_notebook AND expires IS NULL
) TO (concat($title_notebook,'_',$duckcell_number,'.sql')::VARCHAR) (FORMAT $format_file);
EXECUTE export_duckcell(title_notebook:='ExampleNotebook',duckcell_number:=1,format_file:='BLOB');.png)