Database schema change persists after Jupyter kernel restart in notebook cell
0 reputation · 28 Nov 2025, 16:55 UTC
Goal
Determine whether a Jupyter notebook can automatically roll back a database schema change executed in a code cell when the cell raises an exception or the kernel restarts.
Constraints
Restarting the kernel clears in-memory execution state but does not reverse committed DDL against an external database. The %reset magic clears the user namespace without touching persisted rows or tables. Notebook format version 7 stores kernel metadata but defines no rollback mechanism for schema migrations. Behavior may differ between Jupyter Notebook 6.x and 7.x and across kernel implementations, and external databases are not aware of Jupyter cell execution boundaries.
Questions
- Does Jupyter provide any built-in hook to undo a schema change when a dependent cell fails?
- Should transaction boundaries be tied to cell execution, kernel restart, or notebook save?
- Is there a version-specific difference in how Jupyter 6.x and 7.x handle uncommitted database state after a kernel restart?