MCPcopy Create free account
hub / github.com/Borvik/vscode-postgres / run

Method run

src/commands/selectDatabase.ts:10–29  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

8
9export class selectDatabaseCommand extends BaseCommand {
10 async run() {
11 // vscode.window.showInformationMessage('Select Database!');
12 let connectionDetails: IConnection = EditorState.connection;
13 if (!connectionDetails) return;
14
15 const connection = await Database.createConnection(connectionDetails, 'postgres');
16
17 let databases: string[] = [];
18 try {
19 const res = await connection.query('SELECT datname FROM pg_database WHERE datistemplate = false;');
20 databases = res.rows.map<string>(database => database.datname);
21 } finally {
22 await connection.end();
23 }
24
25 //vscode.window.showInputBox
26 const db = await vscode.window.showQuickPick(databases, {placeHolder: 'Select a database'});
27 if (!db) return;
28 EditorState.connection = Database.getConnectionWithDB(connectionDetails, db);
29 }
30}

Callers

nothing calls this directly

Calls 3

createConnectionMethod · 0.80
showQuickPickMethod · 0.80
getConnectionWithDBMethod · 0.80

Tested by

no test coverage detected