MCPcopy Create free account
hub / github.com/CloudOrc/SolidUI / MySQLClient

Class MySQLClient

solidui/datasource_plugin/base.py:102–125  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

100
101
102class MySQLClient(BaseJdbcClient):
103 def get_databases(self):
104 cursor = self.conn.cursor()
105 cursor.execute("SHOW DATABASES")
106 return [db[0] for db in cursor]
107
108 def get_tables(self, database):
109 cursor = self.conn.cursor()
110 cursor.execute(f"SHOW TABLES FROM {database}")
111 return [table[0] for table in cursor]
112
113 def run_query(self, sql):
114 cursor = self.conn.cursor()
115 cursor.execute(sql)
116 column_names = [col[0] for col in cursor.description]
117 rows = [column_names] # First row is column names
118
119 for row in cursor.fetchall():
120 rows.append([str(col) if col is not None else None for col in row])
121
122 return rows
123
124 def generate_select_all_data_sql(self, database, table_name):
125 return f"SELECT * FROM {database}.{table_name}"

Callers 1

create_clientMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected