Photo by Clark Van Der Beken on Unsplash

Writing Code with Github Copilot and ChatGPT Together — II (Databases)

Berk Orbay
DataBulls
Published in
3 min readAug 21, 2023

--

This is a follow-up on the first post. The specific case for this post is database operations, namely PostgreSQL.

My first formal course on relational databases dates back almost 18 years. Over the years, I had to deal with a lot of “database technologies”. In addition to RDBMS, some NoSQL schemas, filesystem databases, or in-memory ones are both local and on the cloud. Even though rarely, I had to deal with “in-database” calculations, distributed processing, etc.

How to “database”?

My main problem is, I forget the syntax. Usually, I have a fairly good idea about how to write a query, but I frequently get interrupted by the little details. Therefore I get errors and I have had to reiterate a couple of times. I’m not talking about complex queries with the length of a giraffe and the innuendo of an esoteric cult.

Recently, I had to build a DB using PostgreSQL. It is one of the (even if not “the”) most popular DB technologies and it has been around for quite some time. It means plenty of documentation and lots of questions at Stackoverflow. So, everything should be ok if I take some time and read some tutorials and some of the documentation?

Bam bam bam!

But, no! I don’t have time for documentation, tutorials, etc. I just have to get what I want from the DB and I want to move on. Guess what? I can do it. I just ask ChatGPT for some boilerplate code for a Python project. I write initial comments on VS Code and Github Copilot autocompletes the rest for me. As with any writing aid, you need to calibrate a bit. But, the amount of supervision is much less compared to other tasks.

It also makes sense. SQL querying, regardless of the technology, is fairly structured. Most conventions are around for a long time and operations are well-defined. Also, the queries I used for this experiment were never complex. I also got great help when I structure my tables, defining indexes, and setting types (syntax is more volatile for this kind of operation).

Conclusion

Database management at the introductory level was never ever easier than this. It always had solid, straightforward logic but you might be tangled up by syntax or other systematic issues. Here LLMs shine the brightest.

More…

--

--

Berk Orbay
DataBulls

Current main interests are #OR and #RL. You may reach me at Linkedin.