Sql data store
Defines an abstract base class to create a SQL data store.
This module defines the BaseSQLDataStore class, which serves as an abstract base class for all connectors in the retrieval system.
References
NONE
BaseSQLDataStore
Bases: ABC
Abstract base class for SQL data stores.
This class defines the interface for all SQL data store implementations. Subclasses must implement the abstract methods.
create(**kwargs)
abstractmethod
Create data using available information in kwargs.
This method must be implemented by subclasses to create data in the data store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
**kwargs |
Any
|
A dictionary of information to create data. |
{}
|
Raises:
Type | Description |
---|---|
NotImplementedError
|
If the method is not implemented. |
delete(filters=None, allow_delete_all=False, **kwargs)
abstractmethod
Delete data in the data store using filters.
This method must be implemented by subclasses to delete data in the data store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filters |
QueryFilter | None
|
Filters to apply to the query. Defaults to None. |
None
|
allow_delete_all |
bool
|
A flag to allow deleting all data. Defaults to False. |
False
|
**kwargs |
Any
|
A dictionary of additional information to support the delete method. |
{}
|
Raises:
Type | Description |
---|---|
NotImplementedError
|
If the method is not implemented. |
query(query, params=None)
abstractmethod
async
Executes raw SQL query.
This method must be implemented by subclasses to execute a raw SQL query. Use this method for raw queries, complex queries, or for executing a query generated by LLM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
query |
str
|
The query string to execute. |
required |
params |
dict[str, Any] | None
|
Parameters to bind to the query. Defaults to None. |
None
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A DataFrame of query results. |
Raises:
Type | Description |
---|---|
NotImplementedError
|
If the method is not implemented. |
read(filters=None, options=None, **kwargs)
abstractmethod
Read data from the data store using optional filters and options.
This method must be implemented by subclasses to read data from the data store. Use this method for simple queries with filters and options.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
filters |
QueryFilter | None
|
Filters to apply to the query. Defaults to None. |
None
|
options |
QueryOptions | None
|
Options to apply to the query. Defaults to None. |
None
|
**kwargs |
Any
|
A dictionary of additional information to support the read method. |
{}
|
Returns:
Type | Description |
---|---|
DataFrame
|
pd.DataFrame: A DataFrame of query results. |
Raises:
Type | Description |
---|---|
NotImplementedError
|
If the method is not implemented. |
update(update_values, filters=None, **kwargs)
abstractmethod
Update data in the data store using optional filters and update values.
This method must be implemented by subclasses to update data in the data store.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
update_values |
dict[str, Any]
|
Values to update in the data store. |
required |
filters |
QueryFilter | None
|
Filters to apply to the query. Defaults to None. |
None
|
**kwargs |
Any
|
A dictionary of additional information to support the update method. |
{}
|
Raises:
Type | Description |
---|---|
NotImplementedError
|
If the method is not implemented. |