feat(datasource): Database connection Renewal (#2359)

Co-authored-by: aries_ckt <916701291@qq.com>
Co-authored-by: Fangyin Cheng <staneyffer@gmail.com>
Co-authored-by: ‘yanzhiyonggit config --global user.email git config --global user.name ‘yanzhiyong <zhiyong.yan@clife.cn>
This commit is contained in:
云锋
2025-02-22 18:44:21 +08:00
committed by GitHub
parent e4b329ee21
commit 94b51284e0
132 changed files with 689 additions and 501 deletions

View File

@@ -133,7 +133,7 @@ class SparkConnector(BaseConnector):
rows.append(row)
return rows
def query_ex(self, sql: str):
def query_ex(self, sql: str, timeout: Optional[float] = None):
"""Execute sql command."""
rows = self.run(sql)
field_names = rows[0]

View File

@@ -38,7 +38,8 @@ class TuGraphParameters(BaseDatasourceParameters):
"Database password, you can write your password directly, of course, "
"you can also use environment variables, such as "
"${env:DBGPT_DB_PASSWORD}"
)
),
"tags": "privacy",
},
)
port: int = field(

View File

@@ -46,7 +46,8 @@ class ClickhouseParameters(BaseDatasourceParameters):
"Database password, you can write your password directly, of course, "
"you can also use environment variables, such as "
"${env:DBGPT_DB_PASSWORD}"
)
),
"tags": "privacy",
},
)
http_pool_maxsize: int = field(

View File

@@ -24,7 +24,11 @@ from dbgpt.util.i18n_utils import _
)
@dataclass
class DorisParameters(RDBMSDatasourceParameters):
"""Doris connection parameters."""
"""Doris connection parameters.
Doris has a same protocol with MySQL, so we suggest to use MySQL connector to
connect Doris.
"""
__type__ = "doris"
driver: str = field(

View File

@@ -50,7 +50,11 @@ class HiveParameters(BaseDatasourceParameters):
default="", metadata={"help": _("Username for authentication")}
)
password: str = field(
default="", metadata={"help": _("Password for LDAP or CUSTOM auth")}
default="",
metadata={
"help": _("Password for LDAP or CUSTOM auth"),
"tags": "privacy",
},
)
# Kerberos parameters
@@ -170,3 +174,9 @@ class HiveConnector(RDBMSConnector):
def get_charset(self):
"""Get character_set of current database."""
return "UTF-8"
def _format_sql(self, sql: str) -> str:
"""Format sql."""
sql = super()._format_sql(sql)
# remove ';' at the end of sql
return sql.rstrip(";")