Created
March 15, 2025 11:23
-
-
Save mrjsj/c40fa5ba696da7c96de8fb561e803049 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!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
copy ( | |
select | |
"json" | |
from _duckdb_ui.notebook_versions | |
where 1=1 | |
and title = 'MySingleNotebook' | |
and expires is null | |
) to 'exported-notebook.json'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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