src.database.base_adapter.DatabaseAdapter
Bases: ABC
Abstract base class defining the interface for database operations.
This class serves as a template for implementing database adapters, ensuring consistent interface across different database backends. All database implementations must inherit from this class and implement its abstract methods.
Methods:
Example
class MyDatabaseClient(DatabaseAdapter):
async def add(self, document, index_name):
# Implementation for adding documents
pass
async def search(self, query, index_name):
# Implementation for searching documents
pass
async def reset(self, index_name):
# Implementation for resetting the database
pass
Source code in src/database/base_adapter.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 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 71 72 73 74 75 76 77 78 79 80 81 82 |
|
add(*args, **kwargs)
abstractmethod
async
Add data to the database.
This abstract method must be implemented by concrete database adapters to handle data insertion operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Variable length argument list for flexibility across implementations |
()
|
|
**kwargs
|
Arbitrary keyword arguments for flexibility across implementations |
{}
|
Raises:
Type | Description |
---|---|
NotImplementedError
|
If the concrete class doesn't implement this method |
Source code in src/database/base_adapter.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 |
|
reset(*args, **kwargs)
abstractmethod
async
Reset or clear data in the database.
This abstract method must be implemented by concrete database adapters to handle database reset operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Variable length argument list for flexibility across implementations |
()
|
|
**kwargs
|
Arbitrary keyword arguments for flexibility across implementations |
{}
|
Raises:
Type | Description |
---|---|
NotImplementedError
|
If the concrete class doesn't implement this method |
Source code in src/database/base_adapter.py
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
|
search(*args, **kwargs)
abstractmethod
async
Search for data in the database.
This abstract method must be implemented by concrete database adapters to handle search operations.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
*args
|
Variable length argument list for flexibility across implementations |
()
|
|
**kwargs
|
Arbitrary keyword arguments for flexibility across implementations |
{}
|
Raises:
Type | Description |
---|---|
NotImplementedError
|
If the concrete class doesn't implement this method |
Source code in src/database/base_adapter.py
52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
|