Database¶
database ¶
Classes¶
Database ¶
Bases: AsyncContextMixin, ABC
Abstract base class for database containers.
All database implementations should inherit from this class and implement the required abstract methods. This ensures a consistent interface across different database backends.
The class provides: 1. Lifecycle management through AsyncContextMixin (init/close) 2. Health check interface (ping) 3. Raw query execution interface (exec)
Example
Functions¶
ping abstractmethod async ¶
Check database connectivity.
Returns:
| Type | Description |
|---|---|
bool | True if database is reachable and healthy, False otherwise. |
Note
Implementations should not raise exceptions. Instead, catch any errors and return False.
Source code in audex/lib/database/__init__.py
exec abstractmethod async ¶
Execute a raw database command.
This method provides a way to execute native database commands when ORM abstractions are insufficient or when optimization requires direct database access.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*args | Any | Positional arguments for the database command. | () |
**kwargs | Any | Database-specific command parameters. | {} |
Returns:
| Type | Description |
|---|---|
Any | Database-specific result object. |
Raises:
| Type | Description |
|---|---|
RuntimeError | If the execution fails. |
Note
The exact signature and return type will vary by database implementation. Refer to specific database class documentation for details.
Source code in audex/lib/database/__init__.py
options: show_root_heading: true show_source: true heading_level: 2 members_order: source show_signature_annotations: true separate_signature: true