mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-09-27 12:33:16 +00:00
ci: make ci happy lint the code, delete unused imports
Signed-off-by: yihong0618 <zouzou0208@gmail.com>
This commit is contained in:
@@ -3,27 +3,27 @@
|
||||
|
||||
import pymysql
|
||||
|
||||
class MySQLOperator:
|
||||
"""Connect MySQL Database fetch MetaData For LLM Prompt
|
||||
Args:
|
||||
|
||||
Usage:
|
||||
class MySQLOperator:
|
||||
"""Connect MySQL Database fetch MetaData For LLM Prompt
|
||||
Args:
|
||||
|
||||
Usage:
|
||||
"""
|
||||
|
||||
default_db = ["information_schema", "performance_schema", "sys", "mysql"]
|
||||
|
||||
def __init__(self, user, password, host="localhost", port=3306) -> None:
|
||||
|
||||
self.conn = pymysql.connect(
|
||||
host=host,
|
||||
user=user,
|
||||
port=port,
|
||||
passwd=password,
|
||||
charset="utf8mb4",
|
||||
cursorclass=pymysql.cursors.DictCursor
|
||||
cursorclass=pymysql.cursors.DictCursor,
|
||||
)
|
||||
|
||||
def get_schema(self, schema_name):
|
||||
|
||||
with self.conn.cursor() as cursor:
|
||||
_sql = f"""
|
||||
select concat(table_name, "(" , group_concat(column_name), ")") as schema_info from information_schema.COLUMNS where table_schema="{schema_name}" group by TABLE_NAME;
|
||||
@@ -31,7 +31,7 @@ class MySQLOperator:
|
||||
cursor.execute(_sql)
|
||||
results = cursor.fetchall()
|
||||
return results
|
||||
|
||||
|
||||
def get_index(self, schema_name):
|
||||
pass
|
||||
|
||||
@@ -43,10 +43,10 @@ class MySQLOperator:
|
||||
cursor.execute(_sql)
|
||||
results = cursor.fetchall()
|
||||
|
||||
dbs = [d["Database"] for d in results if d["Database"] not in self.default_db]
|
||||
dbs = [
|
||||
d["Database"] for d in results if d["Database"] not in self.default_db
|
||||
]
|
||||
return dbs
|
||||
|
||||
def get_meta(self, schema_name):
|
||||
pass
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user