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');Thanks, i already do that. The goal is to stay in DuckDB/MotherDuck ecosystem for simple analysis. I would like avoid deploy python uv venv for not complex analysis and not complex transformation.
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
.png)