paint-brush
My Experience using GitHub Copilot for SQL Developmentby@nitishgaddam
12,275 reads
12,275 reads

My Experience using GitHub Copilot for SQL Development

by Nitish GaddamAugust 2nd, 2023
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

This article provides a comprehensive review of the experience using GitHub Copilot, an AI-powered coding assistant, specifically for SQL development. It highlights Copilot's impressive auto-completion capabilities for table creation, intelligent code suggestions, and contextual formatting. Additionally, the article explores the potential impact of Copilot on software development workflows and discusses how AI technologies are transforming the SQL coding process for developers.
featured image - My Experience using GitHub Copilot for SQL Development
Nitish Gaddam HackerNoon profile picture


As an avid SQL developer, I was intrigued when GitHub Copilot was introduced as an AI-powered coding assistant. With the promise of streamlining my SQL development process, I couldn't resist giving it a try. In this article, I will share my experience using GitHub Copilot for SQL and explore how it impacted my coding efficiency.


Start off by creating an account and then installing Github Copilot on your IDE. You should be able to find it in your extensions.



Getting Started with GitHub Copilot for SQL

After installing the GitHub Copilot extension in my VSCode environment, I was excited to put it to the test. I opened a new SQL file, set the type to SQL, and began writing a comment to provide context for the query I intended to create. Copilot immediately started suggesting lines of code based on the context I provided, and I was amazed at how accurate and relevant the suggestions were.



Auto-Completion example



Efficient Function Creation

One of the standout features of GitHub Copilot for SQL was its ability to assist in creating SQL functions. I started by writing a descriptive function name, and with a quick press of the "Tab" key, Copilot automatically completed the function structure for me. This feature saved me considerable time, especially when creating common functions that I frequently use in my projects.


Intuitive Comment-Based Suggestions

As a seasoned SQL developer, I often find myself writing comments before diving into the code to provide a clear understanding of my intentions. GitHub Copilot brilliantly leverages these comments to generate code that aligns with my objectives. When I wrote a comment describing what I wanted a function to do, Copilot not only provided the function structure but also filled it with appropriate SQL statements and logic.


Another example of using GitHub Copilot to create a function. We can build on it and ask more specific instructions like using a window function to perform the same function for example.


Code Completion at Its Finest

GitHub Copilot's code completion capabilities were truly remarkable. While typing SQL statements, Copilot anticipated what I was going to write and automatically suggested the tables and columns I intended to use. This saved me from repetitive typing and helped prevent errors, especially when working with large and complex databases.


Contextual Formatting and Debugging

Another impressive aspect of GitHub Copilot was its ability to format the code in my preferred style. Whether it was indentation, line breaks, or code blocks, Copilot intuitively adhered to my coding conventions. Additionally, while writing debug messages, Copilot accurately completed the code, ensuring that I didn't miss any crucial debugging points.


This is a quick example of using GitHub Copilot in VS Code to write some queries.


Overcoming PL/SQL Challenges

Although GitHub Copilot is predominantly trained in popular programming languages, I was pleased to find that it still proved useful in dealing with PL/SQL. While it might not have been as proficient as with other languages, it did assist me in generating repetitive PL/SQL code blocks and simplified some of the boilerplate tasks.


Limitations and Room for Improvement

Despite its remarkable capabilities, GitHub Copilot does have limitations, especially when it comes to understanding the specifics of the database schema. Since it does not connect to the database, it relies solely on the information available in the current file. This means that the more context and domain-specific information I provided in my comments and queries, the better the suggestions Copilot offered.


Conclusion

My experience using GitHub Copilot for SQL was undoubtedly positive. It significantly improved my coding efficiency by providing accurate and contextually relevant code suggestions. Its intuitive handling of function creation, code completion, and formatting streamlined my development process and saved me valuable time and effort. Although it had its limitations, especially with less common languages like PL/SQL, I believe that as the tool evolves, it will become an indispensable asset for SQL developers, making the coding process more efficient and enjoyable.