Dataset Operations¶
Source: src/memframe/main.py
OpsWrapper is the public dataset-operation interface exposed through
MemFrame. It manages uploaded datasets, tracks the active dataset, and reads
or records operation history. Each public method has an asynchronous
a-prefixed form and a synchronous form. The implementations live on
OpsMixin (src/memframe/db_manager/ops.py), which MemFrame inherits, and
the connection lifecycle lives on its ConnectorManager.
Public API¶
| Synchronous | Asynchronous | Purpose |
|---|---|---|
list_tables() |
await alist_tables() |
List successful uploads |
set_active(data_id) |
await aset_active(data_id) |
Set the active dataset |
get_active_table() |
await aget_active_table() |
Read the active dataset ID |
delete_table(data_id=None, filename=None) |
await adelete_table(data_id=None, filename=None) |
Delete an uploaded dataset |
list_operations(data_id=None) |
await alist_operations(data_id=None) |
List operation history |
retrieve_operation(data_id, opidx) |
await aretrieve_operation(data_id, opidx) |
Resolve an operation table name |
Dataset Management¶
List Uploaded Datasets¶
The result is ordered from newest to oldest:
[
{"data_id": "a1b2c3", "filename": "customers.csv"},
{"data_id": "d4e5f6", "filename": "orders.parquet"},
]
Only registry entries whose upload completed successfully are returned.
Select the Active Dataset¶
Setting an active dataset first verifies that its upload table exists. Methods
that accept an optional data_id use the active dataset when no ID is given.
Delete a Dataset¶
Delete by data_id:
Delete by original filename:
Deletion drops the dataset's generated transient tables, drops its upload table, removes its registry records, and clears the active dataset when necessary.
Warning
Dataset deletion is permanent.
Operation History¶
List the recorded operations for a dataset:
Each record contains opidx, operation_type, table_name, and created_at.
When no data_id is supplied, list_operations uses the active dataset.
Retrieve the generated table name for one operation:
Operation recording is handled internally by memFrame when library operations create generated tables.
Errors¶
- Operations that require a database raise
RuntimeErrorwhen not connected. - Selecting an unknown
data_idraisesValueError. - Deletion requires either
data_idorfilename. - Listing operations without a supplied or active dataset raises
ValueError.
API Reference¶
memframe.main.MemFrame
¶
Bases: ContextManager, OpsMixin