mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-25 19:39:35 +00:00
Fixed the issue when the MySQL table name had the keyword in it
This commit is contained in:
parent
dbf8b20c0b
commit
34aa73fa76
@ -419,14 +419,14 @@ class Database:
|
||||
def get_indexes(self, table_name):
|
||||
"""Get table indexes about specified table."""
|
||||
session = self._db_sessions()
|
||||
cursor = session.execute(text(f"SHOW INDEXES FROM {table_name}"))
|
||||
cursor = session.execute(text(f"SHOW INDEXES FROM `{table_name}`"))
|
||||
indexes = cursor.fetchall()
|
||||
return [(index[2], index[4]) for index in indexes]
|
||||
|
||||
def get_show_create_table(self, table_name):
|
||||
"""Get table show create table about specified table."""
|
||||
session = self._db_sessions()
|
||||
cursor = session.execute(text(f"SHOW CREATE TABLE {table_name}"))
|
||||
cursor = session.execute(text(f"SHOW CREATE TABLE `{table_name}`"))
|
||||
ans = cursor.fetchall()
|
||||
res = ans[0][1]
|
||||
res = re.sub(r"\s*ENGINE\s*=\s*InnoDB\s*", " ", res, flags=re.IGNORECASE)
|
||||
|
Loading…
Reference in New Issue
Block a user