Documentation Index
Fetch the complete documentation index at: https://docs.pixeltable.com/llms.txt
Use this file to discover all available pages before exploring further.
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()andget_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
Usehistory() for a human-readable summary of all changes.
Programmatic access to version metadata
Useget_versions() to access version data programmatically.
(4, ‘data’, 1)
Access a specific version
Usepxt.get_table('table_name:version') to get a read-only handle to a
specific version:
Revert to previous version
Userevert() to undo the most recent change. This is irreversible.
4
3
Create point-in-time snapshots
Snapshots freeze a table’s state for reproducibility. Unlikerevert(),
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 rowsupdate()- modifying rowsdelete()- removing rowsadd_column()/add_computed_column()- schema changesdrop_column()- schema changesrename_column()- schema changes
history()- Human-readable DataFrame showing all changesget_versions()- List of dictionaries for programmatic access
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
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 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
- Data sharing - Share tables between environments
- Iterative development - Fast feedback during development