Skip to main content
Open in Kaggle  Open in Colab  Download Notebook
This documentation page is also available as an interactive notebook. You can launch the notebook in Kaggle or Colab, or download it for use with an IDE or local Jupyter installation, by clicking one of the above links.
Undo mistakes, audit changes, and create point-in-time snapshots of your data.

Problem

You need to track what changed in your data pipeline, undo accidental modifications, or preserve a specific state for reproducibility.

Solution

What’s in this recipe:
  • View version history with history() and get_versions()
  • Access specific versions with pxt.get_table('table:N')
  • Undo changes with revert()
  • Create point-in-time snapshots with pxt.create_snapshot()

Setup

Connected to Pixeltable database at: postgresql+psycopg://postgres:@/pixeltable?host=/Users/pjlb/.pixeltable/pgdata
Created directory ‘version_demo’.
<pixeltable.catalog.dir.Dir at 0x13ce91c00>

Create a table and make some changes

Every data or schema change creates a new version.
Created table ‘products’.
Inserting rows into `products`: 0 rows [00:00, ? rows/s]
Inserting rows into `products`: 3 rows [00:00, 432.95 rows/s]
Inserted 3 rows with 0 errors.
3 rows inserted, 6 values computed.
Added 3 column values with 0 errors.
3 rows updated, 6 values computed.
Inserting rows into `products`: 0 rows [00:00, ? rows/s]
Inserting rows into `products`: 1 rows [00:00, 297.47 rows/s]
1 row updated, 3 values computed.
Inserting rows into `products`: 0 rows [00:00, ? rows/s]
Inserting rows into `products`: 1 rows [00:00, 661.46 rows/s]
Inserted 1 row with 0 errors.
1 row inserted, 3 values computed.

View version history

Use history() for a human-readable summary of all changes.

Programmatic access to version metadata

Use get_versions() to access version data programmatically.
(4, ‘data’, 1)

Access a specific version

Use pxt.get_table('table_name:version') to get a read-only handle to a specific version:

Revert to previous version

Use revert() to undo the most recent change. This is irreversible.
4
3

Create point-in-time snapshots

Snapshots freeze a table’s state for reproducibility. Unlike revert(), snapshots preserve the data indefinitely.
Inserting rows into `products`: 0 rows [00:00, ? rows/s]
Inserting rows into `products`: 1 rows [00:00, 535.67 rows/s]
Inserted 1 row with 0 errors.Inserting rows into `products`: 0 rows [00:00, ? rows/s]
Inserting rows into `products`: 1 rows [00:00, 558.05 rows/s]

Explanation

What creates a new version:
  • insert() - adding rows
  • update() - modifying rows
  • delete() - removing rows
  • add_column() / add_computed_column() - schema changes
  • drop_column() - schema changes
  • rename_column() - schema changes
Version history methods:
  • history() - Human-readable DataFrame showing all changes
  • get_versions() - List of dictionaries for programmatic access
Accessing specific versions:
  • pxt.get_table('table_name:N') - Get read-only handle to version N
  • Useful for comparing data across versions, auditing changes, or recovering specific values
  • Version handles are read-only—you cannot modify historical versions
Reverting:
  • revert() undoes the most recent version
  • Can call multiple times to go back further
  • Cannot revert past version 0
  • Cannot revert if a snapshot references that version
Snapshots vs revert:
  • Snapshots are persistent, named, point-in-time copies
  • revert() permanently removes the latest version
  • Use snapshots when you need to preserve state for reproducibility
  • Use revert() to undo mistakes

See also

Last modified on June 24, 2026