Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save sashapodgoreanu/88e280611f38a957ce159cc8dd09b300 to your computer and use it in GitHub Desktop.
Save sashapodgoreanu/88e280611f38a957ce159cc8dd09b300 to your computer and use it in GitHub Desktop.
The DuckDB UI stores notebook content in an internal database called _duckdb_ui. You can query and export notebook content, as well as insert new definitions into the database. Warning: Modifying the internal database may lead to corruption and data loss. Be cautious and use it at your own risk!
copy (
select
"json"
from _duckdb_ui.notebook_versions
where 1=1
and title = 'MySingleNotebook'
and expires is null
) to 'exported-notebook.json';
set variable notebook_content = (select json from 'exported-notebook.json');
set variable notebook_id = uuid();
set variable current_timestamp = now();
begin transaction;
insert into _duckdb_ui.notebooks (id, name, created)
select
getvariable('notebook_id'),
'notebook_' || getvariable('notebook_id'),
getvariable('current_timestamp')
;
insert into _duckdb_ui.notebook_versions (notebook_id, version, title, json, created, expires)
select
getvariable('notebook_id'),
1,
'imported-notebook-' || getvariable('current_timestamp'),
getvariable('notebook_content'),
getvariable('current_timestamp'),
null
;
commit;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment