GPT-3 is a large language model chatbot developed by the artificial intelligence company OpenAI. It has 175 billion parameters and was trained on 570 gigabytes of text. Thanks to that, GPT-3 is able to perform tasks it was not explicitly trained on and with few to no examples.
Compared to its predecessor, GPT-2, which was practically incapable of doing this, GPT-3 has taken a huge step forward and quickly gained popularity around the world. One of its more popular uses is to help you write code in various languages. And now, it can become your assistant in writing SQL queries in DBeaver.
How to use GPT-3 with DBeaver
Thanks to our new feature, you can convert sentences written in human language into SQL. You simply need to describe the desired query and get the result. For example, if you have a table with invoices, you can write something like “show all invoices”, and this request will be converted into a valid Select query.
For DBeaver PRO, GPT-3 will be available out of the box.
To access this feature in the Community version, you first need to install the extension.
In the left toolbar of SQL Editor, you can find a new icon that, when clicked, will open an AI assistant. On the first run, you will see a warning that the metadata information needs to be transferred to OpenAI API.
If you click the Confirm button, you can open a GPT Smart Completion window. On the first launch, you will see the Preferences window. The main thing you need to do is to enter the API token. It’s available via the link for free. All other settings can be left as default, but if you want to change them, please read our documentation for details.
You can use the GPT-3 Smart Completion on any SQL database supported by DBeaver.
Now we can check how it works with an example using our sample SQLite database. Let’s try showing all invoices from our German customers. To do this, just enter the following:
show all invoices from Germany
Next, we will click the Translate button. As you can see, our text was converted into a valid SQL query, and it was automatically executed since we checked the corresponding box in the preferences.
Let’s run the same query but add a condition to it:
show all invoices from Germany with a total more than 4
We got the correct SELECT query that only displays records in which the Total values are more than 4.
You do not need to use the exact same wording as ours to get results.
Plus, you do not have to worry about writing grammatically correct sentences.
An essential feature of GPT is that you can write text in any language, not just English, and it will still be translated correctly. Let’s ask a Smart Completion to write the same query, but this time we will use the German language.
Zeig alle Rechnungen aus Deutschland mit der Gesamtsumme über 4
And again, we got the exact same query as before.
When do you need AI for your queries?
GPT-3 Smart Completion in DBeaver can be useful for writing SQL queries quickly without much effort. You can simplify and speed up your work with its help.
Please remember that, like any artificial intelligence, GPT-3 is imperfect and sometimes makes mistakes. But its capabilities are extensive, and we are going to use them in the future to improve the GPT-3 Smart Completion in DBeaver. We will be glad if you try out the new feature on your databases and share your feedback with us.