mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-15 05:59:59 +00:00
refactor: Refactor datasource module (#1309)
This commit is contained in:
@@ -0,0 +1 @@
|
||||
"""Datasource operators."""
|
||||
|
@@ -1,17 +1,26 @@
|
||||
"""DatasourceOperator class.
|
||||
|
||||
Warning: This operator is in development and is not yet ready for production use.
|
||||
"""
|
||||
from typing import Any
|
||||
|
||||
from dbgpt.core.awel import MapOperator
|
||||
from dbgpt.core.awel.task.base import IN, OUT
|
||||
from dbgpt.datasource.base import BaseConnect
|
||||
|
||||
from ..base import BaseConnector
|
||||
|
||||
|
||||
class DatasourceOperator(MapOperator[str, Any]):
|
||||
def __init__(self, connection: BaseConnect, **kwargs):
|
||||
"""The Datasource Operator."""
|
||||
|
||||
def __init__(self, connection: BaseConnector, **kwargs):
|
||||
"""Create the datasource operator."""
|
||||
super().__init__(**kwargs)
|
||||
self._connection = connection
|
||||
|
||||
async def map(self, input_value: IN) -> OUT:
|
||||
async def map(self, input_value: str) -> Any:
|
||||
"""Execute the query."""
|
||||
return await self.blocking_func_to_async(self.query, input_value)
|
||||
|
||||
def query(self, input_value: str) -> Any:
|
||||
"""Execute the query."""
|
||||
return self._connection.run_to_df(input_value)
|
||||
|
Reference in New Issue
Block a user