MCPcopy Create free account
hub / github.com/sqlchat/sqlchat / getDatabases

Function getDatabases

src/lib/connectors/mysql/index.ts:71–85  ·  view source on GitHub ↗
(connection: Connection)

Source from the content-addressed store, hash-verified

69};
70
71const getDatabases = async (connection: Connection): Promise<string[]> => {
72 const conn = await getMySQLConnection(connection);
73 const [rows] = await conn.query<RowDataPacket[]>(
74 `SELECT schema_name as db_name FROM information_schema.schemata WHERE schema_name NOT IN (?);`,
75 [systemDatabases]
76 );
77 conn.destroy();
78 const databaseList = [];
79 for (const row of rows) {
80 if (row["db_name"]) {
81 databaseList.push(row["db_name"]);
82 }
83 }
84 return databaseList;
85};
86
87const getTableSchema = async (connection: Connection, databaseName: string): Promise<Schema[]> => {
88 const conn = await getMySQLConnection(connection);

Callers 1

newConnectorFunction · 0.70

Calls 1

getMySQLConnectionFunction · 0.85

Tested by

no test coverage detected