Connect GitHub Copilot and Visual Studio Code to Query Service

Last update: 2024-11-07
  • Topics:
  • Queries
    View more on this topic
  • Created for:
  • User
    Developer
IMPORTANT

Before using this integrated tool, you must understand what data is shared with GitHub. Shared data includes contextual information about the code and files being edited (“prompts”) and details about user actions (“user engagement data”). Please review GitHub Copilot’s privacy statement to learn about the data they collect. You must also consider the security implications of involving third-party services, as you are responsible for ensuring compliance with your organization’s data governance policies. Adobe is not responsible for any data-related concerns or issues that may arise from the use of this tool. Consult the GitHub’s documentation for more information.

GitHub Copilot, powered by OpenAI Codex, is an AI-driven tool that enhances your coding experience by suggesting code snippets and entire functions directly within your editor. Integrated with Visual Studio Code (VS Code), Copilot can significantly accelerate your workflow, especially when working with complex queries. Follow this guide to learn how to connect GitHub Copilot and VS Code to the Query Service to write and manage your queries with greater efficiency. For more information on Copilot, visit GitHub’s Copilot product page and the official Copilot documentation.

This document covers the steps required to connect GitHub Copilot and VS Code with Adobe Experience Platform Query Service.

Get started

This guide requires that you already have access to a GitHub account and have signed up for GitHub Copilot. You can sign up from the GitHub website. You also need VS Code. You can download VS Code from their official website.

Once you have installed VS Code and activated your Copilot subscription, acquire your connection credentials for Experience Platform. These credentials are located in the Credentials tab of the Queries workspace in the Platform UI. Read the credentials guide to learn how to find these values in the Platform UI. Please contact your organization administrator if you do not currently have access to the Queries workspace.

Required Visual Studio Code extensions

The following Visual Studio Code extensions are required to effectively manage and query your Platform SQL databases directly within the code editor. Download and install these extensions.

  • SQLTools: Use the SQLTools extension to manage and query multiple SQL databases. It includes features like a query runner, SQL formatter, and connection explorer, with support for additional drivers to boost developer productivity. Read the overview on Visual Studio Marketplace for more details.
  • SQLTools PostgreSQL/Cockroach Driver: This extension enables you to connect, query, and manage PostgreSQL and CockroachDB databases directly within your code editor.

The next extensions enable GitHub Copilot and its chat features.

Create connection

Select the cylinder icon (The cylinder icon.) in the left navigation of VS Code, followed by Add New Connection or the cylinder plus icon (The cylinder plus icon.).

The Visual Studio Code UI with the SQL Tool extension and Add new connection highlighted.

The Connection Assistant appears. Select the PostgreSQL database driver.

The SQLTools settings page in VS Code with PostgreSQl highlighted.

Input connection settings

The Connection Settings view appears. Enter your Platform connection credentials into the appropriate fields of the SQLTools Connection Assistant. The required values are explained in the table below.

Property Description
Connection name Provide a “Connection name” like Prod_MySQL_Server that is descriptive and clearly indicates its purpose (for example, a production environment for a MySQL server). Best practices include:
  • Following your organization’s naming conventions to ensure that it is unique within the system.
  • Keep it concise to maintain clarity and avoid confusion with other connections.
  • Include relevant details about the connection’s function or environment in the name.
Connect using Use the Server and Port option to specify the server’s address (hostname) and the port number to establish a direct connection to Platform
Server address Enter the Host value provided in your Platform Postgres credentials, such as acmeprod.platform-query.adobe.io.
Port This value is typically 80 for Platform services.
Database Enter the Database value provided in your Platform Postgres credentials, such as prod:all.
Username This property refers to your organization ID. Enter the Username value provided in your Platform Postgres credentials.
Password This property is your access token. Enter the Password value provided in your Platform Postgres credentials.

The Connection Assistant workspace with several settings highlighted.

Next, select Use Password, followed by Save as plaintext in settings from the dropdown menu that appears. The Password field appears. Use this text input field to enter your access token.

The Use password, its dropdown menu and Password field highlighted.

Finally, to enable SSL, select the SSL input field and choose Enabled from the dropdown menu that appears.

The SSL field with Enabled in the dropdown menu highlighted.

TIP

Once you have entered all your credentials, you can test your connection before saving the connection. Scroll down to the bottom of the workspace and select Test Connection.

The Connection Assistant workspace with Test Connection highlighted.

Once you have correctly input your connection details, select Save Connection to confirm your settings.

The Connection Assistant workspace with Save Connection highlighted.

The Review connection details view appears and displays your connection credentials. When you are sure that your connection details are accurate, select Connect Now.

The Review connection details view with Connect Now highlighted.

Your VS Code workspace appears with a suggestion from GitHub Copilot.

A connected SQL session in VS Code.

GitHub Copilot quick guide

Once connected to your Platform instance, you can use Copilot as an AI coding assistant to help you write code faster and with more confidence. This section covers its key features and how to use them.

Getting started with GitHub Copilot

First, ensure that you have the latest version of VS Code installed. An outdated VS Code version can prevent key Copilot features from working as intended. Next, ensure that the Enable Auto Completions setting is enabled. If Copilot is running correctly, the Copilot icon (The Copilot icon) appears in your status bar (if there is an issue, the Copilot error icon displays instead). Select the Copilot icon to open the GitHub Copilot Menu. From the GitHub Copilot Menu, select Edit Settings

The VS Code editor with the GitHub Copilot Menu displayed and the Copilot icon and Edit Settings highlighted.

Scroll down the options and ensure the check box is enabled for the Enable Auto Completions setting.

The settings panel for GitHub Copilot with the Enable Auto Completions check box selected and highlighted.

Code completions

Once you install the GitHub Copilot extension and log in, it automatically activates a feature called Ghost Text, which suggests code completions as you type. These suggestions help you write code more efficiently and with fewer interruptions. You can also use comments to guide the AI code suggestions. This means that non-technical users can convert plain speech into code to explore their data.

The VSCode UI with a code suggestion and the GitHub Copilot icon highlighted.

TIP

If you would like to disable Copilot for a specific file or language, select the icon in the status bar and disable it.

Accept full or partial Ghost Text suggestions

When GitHub Copilot suggests code completions, you can accept either partial or complete suggestions. Select Tab to accept the entire suggestion, or hold down Control (or Command on Mac) and press the right arrow to accept partial text. To dismiss a suggestion, press Escape.

TIP

If you are not getting suggestions, ensure that Copilot is enabled in your file’s language.

The VS Code editor showing a faint gray text suggestion from GitHub Copilot as Ghost Text next to partially typed code.

Alternative suggestions

To cycle through alternative code suggestions, select the arrows in the Copilot dialog.

The VS Code editor showing the Copilot alternative suggestions panel.

Use inline chat

You can also chat with Copilot directly about your code. Use Control (or Command) + I to trigger the inline chat dialog. This feature is used for iterating on your code and refining suggestions in context. You can highlight a block of code and use inline chat to see a different solution proposed by the AI before accepting.

The inline chat window with diff view

Dedicated chat view

You can use a more traditional chat interface with a dedicated chat sidebar to form ideas and strategy, solve coding issues, and discuss implementation details. Select the chat icon (The Copilot Chat icon.) in the VS Code sidebar to open a dedicated chat window.

The GitHub Copilot chat sidebar with the chat icon highlighted.

You can also access chat history by selecting the history icon (The history icon.) at the top of the chat panel.

Next steps

You are now ready to efficiently query your Platform databases directly from your code editor, and use GitHub Copilot’s AI-powered code suggestions to streamline writing and optimizing SQL queries. For more information on how to write and run queries, refer to the guidance for query execution.

On this page