BaseClient
BaseClient
¶
BaseClient(table_name: str)
Bases: ABC
Abstract base class for all client implementations.
This class defines the interface that all concrete client classes must implement.
It provides a common execute
method for dispatching queries based on the
QueryBuilder
's mode and defines abstract methods for the core database
operations.
Subclasses must implement the abstract methods to provide concrete implementations for interacting with a specific database or service.
The table name is used to identify the target table for database operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
table_name
|
str
|
The name of the table to operate on. |
required |
Methods:
Name | Description |
---|---|
execute |
Executes a query constructed by the provided QueryBuilder. |
Source code in supadantic/clients/base.py
31 32 33 34 35 36 37 38 39 40 41 |
|
execute
¶
execute(*, query_builder: QueryBuilder) -> list[dict[str, Any]] | int
Executes a query constructed by the provided QueryBuilder.
This method acts as a dispatcher, selecting the appropriate database operation
based on the query_builder.mode
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query_builder
|
QueryBuilder
|
The QueryBuilder instance containing the query details and execution mode. The mode determines which underlying database operation will be performed. |
required |
Returns:
Type | Description |
---|---|
dict[str, Any] | int
|
A dictionary containing the results of the query for insert, update, or filter operations; or an integer representing the number of affected rows for delete or count operations. The exact structure of the dictionary depends on the specific data returned by the underlying database. |
Source code in supadantic/clients/base.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|