Hexmos의 창립자인 Shrijith Venkatrama는 단 몇 분 만에 코드에서 훌륭한 API 문서를 생성하여 엔지니어링 워크플로를 간소화하는 매우 편리한 도구인 LiveAPI를 구축하고 있습니다.
이 튜토리얼 시리즈에서는 AI 채팅을 사용하여 데이터베이스를 탐색하고 개선하기 위한 간단한 도구인 DBChat을 직접 구축합니다.
자세한 내용은 이전 기사를 참조하세요.
- DBChat 구축 - 간단한 채팅으로 데이터베이스 탐색 및 개선(1부)
- DBChat: Golang에서 장난감 REPL 출시(2부)
- DBChat 파트 3 - 데이터베이스 구성, 연결 및 덤프
- DBChat 및 Gemini를 사용하여 데이터베이스와 채팅(4부)
- 언어 서버 프로토콜 - DBChat 구축(5부)
- DBChat VSCode 확장 만들기 - LSP 백엔드와 핑퐁 상호 작용(6부)
- DBChat용 VSCode 확장 UI 실행(7부)
VSCode 확장에서 DBChat용 TOML 연결 관리자 UI 구축
이전 기사에서는 DBChat VSCode 확장 프로그램에서 간단한 채팅 UI 및 데이터베이스 연결 양식을 위한 프레임워크를 만들었습니다.
이 게시물에서는 DBChat 확장 프로그램이 ~/.dbchat.toml 구성 파일의 [connections] 섹션을 조작하여 항목을 추가/업데이트/삭제하는 방법을 보여 드리겠습니다.
메모리를 새로 고치려면 구성 파일의 구조가 다음과 같아야 합니다.
<code># DBChat 示例配置文件 # 将此文件复制到 ~/.dbchat.toml 并根据需要修改 [connections] # 格式:name = "connection_string" local = "postgresql://postgres:postgres@localhost:5432/postgres" liveapi = "postgresql://user:pwd@ip:5432/db_name" [llm] gemini_key = "the_key"</code>
결과
DBChat 연결 목록:
DBChat 연결 추가/수정:
수정 및 업데이트의 경우 오류 방지를 위해 확인 메시지도 표시됩니다.
연결 생성 요청 처리
먼저 toml 확장 프로그램을 설치합니다.
<code> npm install @iarna/toml</code>
새로운 수입품이 생겼습니다:
<code>import * as fs from 'fs/promises'; import * as path from 'path'; import * as os from 'os'; import * as TOML from '@iarna/toml';</code>
키 구조는 세 가지 작업 모두에 대한 이벤트를 수신하는 메시지 핸들러입니다.
<code> const messageHandler = this._view.webview.onDidReceiveMessage( async (message) => { console.log('Received message:', message); switch (message.command) { case 'saveConnection': console.log('Processing saveConnection command'); const success = await this._saveConnection(message.name, message.connectionString); if (success) { console.log('Connection saved successfully, closing form'); this._showingConnectionForm = false; this._updateView(); } else { console.log('Connection not saved, keeping form open'); } break; case 'cancel': console.log('Processing cancel command'); this._showingConnectionForm = false; this._updateView(); break; case 'editConnection': this._showingConnectionForm = true; this._editingConnection = message.name; // First update the view to show the form await this._updateView(); // Then send the prefill message after a short delay to ensure the form exists setTimeout(() => { this._view.webview.postMessage({ command: 'prefillForm', name: message.name, connectionString: message.connectionString }); }, 100); break; case 'deleteConnection': const choice = await vscode.window.showWarningMessage( `Are you sure you want to delete connection "${message.name}"?`, 'Yes', 'No' ); if (choice === 'Yes') { const deleted = await this._deleteConnection(message.name); if (deleted) { await this._updateView(); // Update view after successful deletion vscode.window.showInformationMessage(`Connection "${message.name}" deleted successfully.`); } } break; } } ); // Add message handler to subscriptions for cleanup context.subscriptions.push(messageHandler);</code>
연결을 저장하는 것은 쉽습니다.
<code> private async _saveConnection(name: string, connectionString: string): Promise<boolean> { console.log('Starting _saveConnection with:', { name, connectionString }); try { const configPath = path.join(os.homedir(), 'dbchat.toml'); console.log('Config path:', configPath); let config: any = { connections: {}, llm: {} }; console.log('Initial config structure:', config); // Read existing config if it exists try { console.log('Attempting to read existing config file...'); const fileContent = await fs.readFile(configPath, 'utf-8'); console.log('Existing file content:', fileContent); console.log('Parsing TOML content...'); config = TOML.parse(fileContent); console.log('Parsed config:', config); // Ensure connections section exists config.connections = config.connections || {}; console.log('Config after ensuring connections exist:', config); } catch (error: any) { console.log('Error reading config:', error); if (error.code !== 'ENOENT') { console.error('Unexpected error reading config:', error); throw error; } console.log('Config file does not exist, will create new one'); } // Check if connection already exists if (config.connections[name]) { console.log(`Connection "${name}" already exists, showing confirmation dialog`); const choice = await vscode.window.showWarningMessage( `Connection "${name}" already exists. Do you want to overwrite it?`, 'Yes', 'No' ); console.log('User choice for overwrite:', choice); if (choice !== 'Yes') { console.log('User declined to overwrite, returning false'); return false; } } // Update the connection config.connections[name] = connectionString; console.log('Updated config:', config); // Convert config to TOML and write back to file console.log('Converting config to TOML...'); const tomlContent = TOML.stringify(config); console.log('Generated TOML content:', tomlContent); // Preserve the header comments const finalContent = `# DBChat Sample Configuration File # Copy this file to ~/.dbchat.toml and modify as needed ${tomlContent}`; console.log('Final content to write:', finalContent); console.log('Writing to file...'); await fs.writeFile(configPath, finalContent, 'utf-8'); console.log('File written successfully'); // Update view immediately after successful file write this._showingConnectionForm = false; console.log('Form hidden, updating view'); this._updateView(); await vscode.window.showInformationMessage(`Connection "${name}" saved successfully!`, { modal: false }); return true; } catch (error) { console.error('Error in _saveConnection:', error); if (error instanceof Error) { console.error('Error stack:', error.stack); } await vscode.window.showErrorMessage(`Failed to save connection: ${error}`); return false; } } </boolean></code>
연결 목록
<code> private async _getConnections(): Promise { try { const configPath = path.join(os.homedir(), 'dbchat.toml'); const fileContent = await fs.readFile(configPath, 'utf-8'); const config = TOML.parse(fileContent); return config.connections || {}; } catch (error) { console.error('Error reading connections:', error); return {}; } }</code>
연결 삭제
<code> private async _deleteConnection(name: string): Promise<boolean> { try { const configPath = path.join(os.homedir(), 'dbchat.toml'); const fileContent = await fs.readFile(configPath, 'utf-8'); const config = TOML.parse(fileContent); if (!config.connections || !config.connections[name]) { await vscode.window.showErrorMessage(`Connection "${name}" not found.`); return false; } delete config.connections[name]; const tomlContent = TOML.stringify(config); const finalContent = `# DBChat Sample Configuration File # Copy this file to ~/.dbchat.toml and modify as needed ${tomlContent}`; await fs.writeFile(configPath, finalContent, 'utf-8'); // Show message after file operations are complete vscode.window.showInformationMessage(`Connection "${name}" deleted successfully.`); return true; } catch (error) { console.error('Error deleting connection:', error); vscode.window.showErrorMessage(`Failed to delete connection: ${error}`); return false; } } </boolean></code>
이번 포스팅은 여기까지입니다. 이 구조를 통해 기본 데이터베이스 연결 목록, 추가, 삭제 및 업데이트 작업을 구현합니다.
다음 단계
기본적인 데이터베이스 구성 메커니즘이 있으므로 다음으로 golang LSP를 사용하여 특정 구성에 연결하고, 스키마를 가져오고, 데이터베이스와 채팅하는 등의 기능을 활성화하는 작업을 진행하겠습니다.
위 내용은 VSCode 확장에서 TOML 구성 관리 - DBChat Part 8의 상세 내용입니다. 자세한 내용은 PHP 중국어 웹사이트의 기타 관련 기사를 참조하세요!

JavaScript 문자열 교체 방법 및 FAQ에 대한 자세한 설명 이 기사는 JavaScript에서 문자열 문자를 대체하는 두 가지 방법 인 내부 JavaScript 코드와 웹 페이지의 내부 HTML을 탐색합니다. JavaScript 코드 내부의 문자열을 교체하십시오 가장 직접적인 방법은 대체 () 메소드를 사용하는 것입니다. str = str.replace ( "find", "replace"); 이 메소드는 첫 번째 일치 만 대체합니다. 모든 경기를 교체하려면 정규 표현식을 사용하고 전역 플래그 g를 추가하십시오. str = str.replace (/fi

그래서 여기 당신은 Ajax라는이 일에 대해 배울 준비가되어 있습니다. 그러나 정확히 무엇입니까? Ajax라는 용어는 역동적이고 대화식 웹 컨텐츠를 만드는 데 사용되는 느슨한 기술 그룹을 나타냅니다. 원래 Jesse J에 의해 만들어진 Ajax라는 용어

10 재미있는 jQuery 게임 플러그인 웹 사이트를보다 매력적으로 만들고 사용자 끈적함을 향상시킵니다! Flash는 여전히 캐주얼 웹 게임을 개발하기위한 최고의 소프트웨어이지만 JQuery는 놀라운 효과를 만들 수 있으며 Pure Action Flash 게임과 비교할 수는 없지만 경우에 따라 브라우저에서 예기치 않은 재미를 가질 수 있습니다. jQuery tic 발가락 게임 게임 프로그래밍의 "Hello World"에는 이제 jQuery 버전이 있습니다. 소스 코드 jQuery Crazy Word Composition 게임 이것은 반은 반은 게임이며, 단어의 맥락을 알지 못해 이상한 결과를 얻을 수 있습니다. 소스 코드 jQuery 광산 청소 게임

기사는 JavaScript 라이브러리 작성, 게시 및 유지 관리, 계획, 개발, 테스트, 문서 및 홍보 전략에 중점을 둡니다.

이 튜토리얼은 jQuery를 사용하여 매혹적인 시차 배경 효과를 만드는 방법을 보여줍니다. 우리는 멋진 시각적 깊이를 만드는 계층화 된 이미지가있는 헤더 배너를 만들 것입니다. 업데이트 된 플러그인은 jQuery 1.6.4 이상에서 작동합니다. 다운로드

이 기사는 브라우저에서 JavaScript 성능을 최적화하기위한 전략에 대해 설명하고 실행 시간을 줄이고 페이지로드 속도에 미치는 영향을 최소화하는 데 중점을 둡니다.

이 기사에서는 jQuery 및 Ajax를 사용하여 5 초마다 DIV의 컨텐츠를 자동으로 새로 고치는 방법을 보여줍니다. 이 예제는 RSS 피드의 최신 블로그 게시물을 마지막 새로 고침 타임 스탬프와 함께 가져오고 표시합니다. 로딩 이미지는 선택 사항입니다

Matter.js는 JavaScript로 작성된 2D 강성 신체 물리 엔진입니다. 이 라이브러리를 사용하면 브라우저에서 2D 물리학을 쉽게 시뮬레이션 할 수 있습니다. 그것은 단단한 몸체를 생성하고 질량, 면적 또는 밀도와 같은 물리적 특성을 할당하는 능력과 같은 많은 기능을 제공합니다. 중력 마찰과 같은 다양한 유형의 충돌 및 힘을 시뮬레이션 할 수도 있습니다. Matter.js는 모든 주류 브라우저를 지원합니다. 또한, 터치를 감지하고 반응이 좋기 때문에 모바일 장치에 적합합니다. 이러한 모든 기능을 사용하면 엔진 사용 방법을 배울 수있는 시간이 필요합니다. 이는 물리 기반 2D 게임 또는 시뮬레이션을 쉽게 만들 수 있습니다. 이 튜토리얼에서는 설치 및 사용을 포함한이 라이브러리의 기본 사항을 다루고


핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

SublimeText3 Mac 버전
신 수준의 코드 편집 소프트웨어(SublimeText3)

에디트플러스 중국어 크랙 버전
작은 크기, 구문 강조, 코드 프롬프트 기능을 지원하지 않음

맨티스BT
Mantis는 제품 결함 추적을 돕기 위해 설계된 배포하기 쉬운 웹 기반 결함 추적 도구입니다. PHP, MySQL 및 웹 서버가 필요합니다. 데모 및 호스팅 서비스를 확인해 보세요.

mPDF
mPDF는 UTF-8로 인코딩된 HTML에서 PDF 파일을 생성할 수 있는 PHP 라이브러리입니다. 원저자인 Ian Back은 자신의 웹 사이트에서 "즉시" PDF 파일을 출력하고 다양한 언어를 처리하기 위해 mPDF를 작성했습니다. HTML2FPDF와 같은 원본 스크립트보다 유니코드 글꼴을 사용할 때 속도가 느리고 더 큰 파일을 생성하지만 CSS 스타일 등을 지원하고 많은 개선 사항이 있습니다. RTL(아랍어, 히브리어), CJK(중국어, 일본어, 한국어)를 포함한 거의 모든 언어를 지원합니다. 중첩된 블록 수준 요소(예: P, DIV)를 지원합니다.
