Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangyongchao committed Jan 26, 2025
1 parent c6f175a commit 1a0b4ac
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 19 deletions.
18 changes: 9 additions & 9 deletions lazyllm/docs/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -1541,9 +1541,9 @@
)

add_chinese_doc(
"SqlBaseManager",
"SqlAlchemyManager",
"""\
SqlBaseManager是与数据库进行交互的专用工具。它提供了连接数据库,设置、创建、检查数据表,插入数据,执行查询的方法。
SqlAlchemyManager是与数据库进行交互的专用工具。它提供了连接数据库,设置、创建、检查数据表,插入数据,执行查询的方法。
Arguments:
db_type (str): 目前仅支持"PostgreSQL",后续会增加"MySQL", "MS SQL"
Expand All @@ -1558,9 +1558,9 @@
)

add_english_doc(
"SqlBaseManager",
"SqlAlchemyManager",
"""\
SqlBaseManager is a specialized tool for interacting with databases.
SqlAlchemyManager is a specialized tool for interacting with databases.
It provides methods for creating tables, executing queries, and performing updates on databases.
Arguments:
Expand All @@ -1576,9 +1576,9 @@
)

add_chinese_doc(
"SqlBaseManager.check_connection",
"SqlAlchemyManager.check_connection",
"""\
检查当前SqlBaseManager的连接状态
检查当前SqlAlchemyManager的连接状态
**Returns:**\n
- bool: 连接成功(True), 连接失败(False)
Expand All @@ -1587,7 +1587,7 @@
)

add_english_doc(
"SqlBaseManager.check_connection",
"SqlAlchemyManager.check_connection",
"""\
Check the current connection status of the SqlManagerBase.
Expand All @@ -1598,14 +1598,14 @@
)

add_chinese_doc(
"SqlBaseManager.execute_query",
"SqlAlchemyManager.execute_query",
"""\
执行SQL查询并返回JSON格式的结果。
""",
)

add_english_doc(
"SqlBaseManager.execute_query",
"SqlAlchemyManager.execute_query",
"""\
Executes a SQL query and returns the result in JSON format.
""",
Expand Down
4 changes: 2 additions & 2 deletions lazyllm/tools/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
ReWOOAgent,
)
from .classifier import IntentClassifier
from .sql import SqlBaseManager, SqlManager, MongoDBManager, DBResult, DBStatus
from .sql import SqlAlchemyManager, SqlManager, MongoDBManager, DBResult, DBStatus
from .sql_call import SqlCall
from .tools.http_tool import HttpTool

Expand All @@ -29,7 +29,7 @@
"ReWOOAgent",
"IntentClassifier",
"SentenceSplitter",
"SqlBaseManager",
"SqlAlchemyManager",
"SqlManager",
"MongoDBManager",
"DBResult",
Expand Down
4 changes: 2 additions & 2 deletions lazyllm/tools/sql/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from .sql_manager import SqlManager, SqlBaseManager
from .sql_manager import SqlManager, SqlAlchemyManager
from .mongodb_manager import MongoDBManager
from .db_manager import DBManager, DBResult, DBStatus

__all__ = ["DBManager", "SqlBaseManager", "SqlManager", "MongoDBManager", "DBResult", "DBStatus"]
__all__ = ["DBManager", "SqlAlchemyManager", "SqlManager", "MongoDBManager", "DBResult", "DBStatus"]
4 changes: 0 additions & 4 deletions lazyllm/tools/sql/db_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,9 @@ class CommonMeta(type(ABC), type(ModuleBase)):
pass

class DBManager(ABC, ModuleBase, metaclass=CommonMeta):
DB_TYPE_SUPPORTED = set(["postgresql", "mysql", "mssql", "sqlite", "mongodb"])

def __init__(self, db_type: str):
db_type = db_type.lower()
ModuleBase.__init__(self)
if db_type not in self.DB_TYPE_SUPPORTED:
raise ValueError(f"{db_type} not supported")
self._db_type = db_type
self._desc = None

Expand Down
8 changes: 6 additions & 2 deletions lazyllm/tools/sql/sql_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@
class TableBase(DeclarativeBase):
pass

class SqlBaseManager(DBManager):
class SqlAlchemyManager(DBManager):
DB_TYPE_SUPPORTED = set(["postgresql", "mysql", "mssql", "sqlite"])
DB_DRIVER_MAP = {"mysql": "pymysql"}

def __init__(self, db_type: str, user: str, password: str, host: str, port: int, db_name: str, options_str=""):
db_type = db_type.lower()
if db_type not in self.DB_TYPE_SUPPORTED:
raise ValueError(f"{db_type} not supported")
super().__init__(db_type)
self.user = user
self.password = password
Expand Down Expand Up @@ -213,7 +217,7 @@ class TableInfo(pydantic.BaseModel):
class TablesInfo(pydantic.BaseModel):
tables: list[TableInfo]

class SqlManager(SqlBaseManager):
class SqlManager(SqlAlchemyManager):
PYTYPE_TO_SQL_MAP = {
"integer": sqlalchemy.Integer,
"string": sqlalchemy.Text,
Expand Down

0 comments on commit 1a0b4ac

Please sign in to comment.