API Reference Overview
Welcome to the API reference! This section provides a detailed look at all the functions available in dbzero.
Use the table below to quickly find the function you're looking for and jump to its documentation. 👩💻
Workspace
| Function | Description |
|---|---|
init | Initialize the dbzero workspace at a specific root path. |
open | Open a data prefix and set it as the current working context. |
close | Gracefully shut down dbzero, persisting changes and releasing resources. |
commit | Persist all pending data changes. |
get_current_prefix | Retrieve the currently active prefix. |
get_prefixes | Get a list of all prefixes accessible from the current context. |
get_mutable_prefixes | Get a list of prefixes that are currently open in read-write mode. |
copy_prefix | Copy data from prefix to a file (e.g. for backup purposes). |
Objects
| Function | Description |
|---|---|
fetch | Retrieve a dbzero object instance by its UUID or type (for singletons). |
exists | Check if a UUID points to a valid dbzero object or an existing singleton instance. |
load | Load a dbzero instance recursively into memory as its equivalent native Python representation. |
uuid | Get the unique object ID (UUID) of a dbzero instance. |
set_prefix | Set the persistence prefix for a Memo instance dynamically at runtime. |
get_prefix_of | Return the prefix where given dbzero-managed object resides. |
materialized | Return a "materialized" (fully initialized) version of a @dbzero.memo object. |
Data Types
| Function | Description |
|---|---|
memo | Decorator that transforms a standard Python class into a persistent, dbzero-managed object. |
tuple | Create a new dbzero tuple instance. |
list | Create a new dbzero list instance. |
set | Create a new dbzero set instance. |
dict | Create a new dbzero dictionary instance. |
index | Create a new dbzero index instance for fast lookups. |
bytearray | Create a new dbzero bytearray instance. |
enum | Create a persistent, type-safe enumerated type. |
Query and Tags
| Function | Description |
|---|---|
find | Query for memo objects based on specified search criteria. |
tags | Get a tag manager interface for given memo objects. |
as_tag | Make a searchable tag from a memo instance or class. |
no | Create a negative predicate (NOT condition) for find queries. |
filter | Apply fine-grained, custom filtering logic to a query. |
split_by | Splits a query iterator into groups based on a given criterion. |
init_fast_query | Initializes the fast query caching system using a specified prefix. |
group_by | Perform cached group-and-aggregate queries over a set of objects. |
Snapshots
| Function | Description |
|---|---|
snapshot | Get a read-only snapshot view of dbzero state. |
get_snapshot_of | Get the Snapshot instance from which a given object originates. |
select_new | Refine a query to include only objects created between two snapshots. |
select_deleted | Refine a query to include only objects deleted between two snapshots. |
select_modified | Refine a query to include only objects modified between two snapshots. |
Introspection
| Function | Description |
|---|---|
is_memo | Check if a given object is a dbzero memo class or memo instance. |
is_singleton | Check if a given object is a dbzero singleton instance. |
is_enum | Check if an object is a dbzero enum type. |
is_enum_value | Check if an object is a dbzero enum value. |
get_schema | Introspect all in-memory instances of a @dbzero.memo class to deduce dynamic schema. |
Object Lifecycle
| Function | Description |
|---|---|
weak_proxy | Create a weak reference to a memo object. |
expired | Check if a weak reference proxy has expired (the object was garbage collected). |
getrefcount | Get the number of strong references to a memo object or class. |
Synchronization
| Function | Description |
|---|---|
get_state_num | Return the state number for a given data prefix. |
wait | Block execution until desired prefix reaches target state or timeout occurs. |
async_wait | Pause an asyncio coroutine until a specific data prefix reaches a target state number. |
locked | Stop the autocommit, ensuring that all changes will be made in a scope of single transaction. |
atomic | Open a context manager to group multiple mutating operations into a single indivisible transaction. |
Other
| Function | Description |
|---|---|
assign | Perform bulk attribute updates on one or more memo objects. |
atomic_assign | Perform bulk attribute updates on one or more memo objects within an atomic transaction. |
compare | Perform a deep, content-based comparison of two memo objects to check if they are identical. |
touch | Mark one or more Memo objects as modified without changing their data. |
rename_field | Rename a field for a given memo class. |
hash | Compute a deterministic 64-bit integer hash for any object. |
set_cache_size | Set the maximum size of the in-memory cache. |
clear_cache | Manually evict all objects from the in-memory cache. |
get_config | Retrieve the active configuration settings for dbzero. |
serialize | Convert a dbzero query iterable or enum value into platform-independent binary representation. |
deserialize | Reconstruct a dbzero object from serialized bytes. |