mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-26 03:49:10 +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):
|
def get_indexes(self, table_name):
|
||||||
"""Get table indexes about specified table."""
|
"""Get table indexes about specified table."""
|
||||||
session = self._db_sessions()
|
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()
|
indexes = cursor.fetchall()
|
||||||
return [(index[2], index[4]) for index in indexes]
|
return [(index[2], index[4]) for index in indexes]
|
||||||
|
|
||||||
def get_show_create_table(self, table_name):
|
def get_show_create_table(self, table_name):
|
||||||
"""Get table show create table about specified table."""
|
"""Get table show create table about specified table."""
|
||||||
session = self._db_sessions()
|
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()
|
ans = cursor.fetchall()
|
||||||
res = ans[0][1]
|
res = ans[0][1]
|
||||||
res = re.sub(r"\s*ENGINE\s*=\s*InnoDB\s*", " ", res, flags=re.IGNORECASE)
|
res = re.sub(r"\s*ENGINE\s*=\s*InnoDB\s*", " ", res, flags=re.IGNORECASE)
|
||||||
|
Loading…
Reference in New Issue
Block a user