Add template DB Assistant and exesql sql column description (#2054)

### What problem does this PR solve?

### Type of change

- [x] New Feature (non-breaking change which adds functionality)

---------

Co-authored-by: Kevin Hu <kevinhu.sh@gmail.com>
This commit is contained in:
H 2024-08-22 15:55:11 +08:00 committed by GitHub
parent 20f3f54714
commit 21f2c5838b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 684 additions and 3 deletions

View File

@ -82,9 +82,9 @@ class ExeSQL(ComponentBase, ABC):
continue
try:
query = db.execute_sql(single_sql)
sql_res.append(
{"content": "\n##Total: " + str(query.rowcount) + "\n" + pd.DataFrame(
[i for i in query.fetchmany(size=self._param.top_n)]).to_markdown()})
single_res = pd.DataFrame([i for i in query.fetchmany(size=self._param.top_n)])
single_res.columns = [i[0] for i in query.description]
sql_res.append({"content": "\nTotal: " + str(query.rowcount) + "\n" + single_res.to_markdown()})
except Exception as e:
sql_res.append({"content": "**Error**:" + str(e) + "\nError SQL Statement:" + single_sql})
pass

File diff suppressed because one or more lines are too long