MCPcopy Create free account
hub / github.com/CL-lau/SQL-GPT / get_db_structure_and_index

Method get_db_structure_and_index

sql/SQLOperator.py:210–221  ·  view source on GitHub ↗

根据包含数据库和数据库表的SQL语句获取数据库结构和索引信息 :param sql: 包含数据库和数据库表的SQL语句,例如:SELECT * FROM mydatabase.mytable :return: 数据库结构和索引信息

(self, sql)

Source from the content-addressed store, hash-verified

208 return result
209
210 def get_db_structure_and_index(self, sql):
211 """
212 根据包含数据库和数据库表的SQL语句获取数据库结构和索引信息
213 :param sql: 包含数据库和数据库表的SQL语句,例如:SELECT * FROM mydatabase.mytable
214 :return: 数据库结构和索引信息
215 """
216 db_name, table_name, jdbc = self.extract_database_and_table_from_sql(sql)
217 engine = create_engine('mysql+pymysql://' + self.userNameMap[jdbc] + ':' + self.passwordMap[jdbc] + '@' + jdbc)
218 metadata = MetaData()
219 metadata.bind = engine
220 table_obj = Table(table_name, metadata, autoload=True)
221 return table_obj.columns, table_obj.indexes
222
223 def extract_database_and_table_from_sql(self, sql):
224 """

Callers 1

optimizeSQLMethod · 0.80

Tested by

no test coverage detected