Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: clickhouse connect error fix #958

Merged
merged 9 commits into from
Dec 22, 2023
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion dbgpt/app/scene/chat_db/professional_qa/chat.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def __init__(self, chat_param: Dict):

if self.db_name:
self.database = CFG.LOCAL_DB_MANAGE.get_connect(self.db_name)
self.db_connect = self.database.session
self.tables = self.database.get_table_names()

self.top_k = (
Expand Down
2 changes: 1 addition & 1 deletion dbgpt/app/static/404.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/404/index.html

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
self.__SSG_MANIFEST=new Set([]);self.__SSG_MANIFEST_CB&&self.__SSG_MANIFEST_CB()
173 changes: 173 additions & 0 deletions dbgpt/app/static/_next/static/chunks/pages/_app-9bd25c3bb54ca39c.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/agent/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/chat/[scene]/[id]/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/chat/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/database/index.html

Large diffs are not rendered by default.

Binary file added dbgpt/app/static/icons/doris.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion dbgpt/app/static/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/knowledge/chunk/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/knowledge/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/models/index.html

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dbgpt/app/static/prompt/index.html

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions dbgpt/datasource/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,14 @@ def get_table_comments(self, db_name):
"""
pass

def get_column_comments(self, db_name, table_name):
"""Get column comments.

Args:
table_name (_type_): _description_
"""
pass

def run(self, command: str, fetch: str = "all") -> List:
"""Execute sql command.

Expand Down
1 change: 1 addition & 0 deletions dbgpt/datasource/manages/connect_config_db.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,7 @@ def get_db_config(self, db_name):
else:
raise ValueError("Cannot get database by name" + db_name)

print(result)
fields = [field[0] for field in result.cursor.description]
row_dict = {}
row_1 = list(result.cursor.fetchall()[0])
Expand Down
25 changes: 21 additions & 4 deletions dbgpt/datasource/rdbms/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,20 +292,21 @@ def _query(self, query: str, fetch: str = "all"):
query (str): SQL query to run
fetch (str): fetch type
"""
result = []

print(f"Query[{query}]")
if not query:
return []
return result
cursor = self.session.execute(text(query))
if cursor.returns_rows:
if fetch == "all":
result = cursor.fetchall()
elif fetch == "one":
result = cursor.fetchone()[0] # type: ignore
result = [cursor.fetchone()]
else:
raise ValueError("Fetch parameter must be either 'one' or 'all'")
field_names = tuple(i[0:] for i in cursor.keys())

result = list(result)
result.insert(0, field_names)
return result

Expand Down Expand Up @@ -538,7 +539,8 @@ def get_users(self):
def get_table_comments(self, db_name):
cursor = self.session.execute(
text(
f"""SELECT table_name, table_comment FROM information_schema.tables WHERE table_schema = '{db_name}'""".format(
f"""SELECT table_name, table_comment FROM information_schema.tables
WHERE table_schema = '{db_name}'""".format(
db_name
)
)
Expand All @@ -548,6 +550,21 @@ def get_table_comments(self, db_name):
(table_comment[0], table_comment[1]) for table_comment in table_comments
]

def get_column_comments(self, db_name, table_name):
cursor = self.session.execute(
text(
f"""SELECT column_name, column_comment FROM information_schema.columns
WHERE table_schema = '{db_name}' and table_name = '{table_name}'
""".format(
db_name, table_name
)
)
)
column_comments = cursor.fetchall()
return [
(column_comment[0], column_comment[1]) for column_comment in column_comments
]

def get_database_list(self):
session = self._db_sessions()
cursor = session.execute(text(" show databases;"))
Expand Down
Loading
Loading