Categories
AI Tech

Add ChatGPT to DBeaver

If you use DBeaver as your SQL IDE, here’s how to add AI right now

What you need

  • DBeaver on version 22.3.5 or higher
  • An OpenAI account and a new API key

Set-Up

Download DBeaver Community Edition https://dbeaver.io/download/

Register for an OpenAI account if you don’t currently have one https://auth0.openai.com/u/signup/

Install DBeaver

Create sample database

You can also access this test database tool through Help > Create Test Database.

“Wait, why do I need the sample database?”

I assume you don’t have a huge personal database ready to go, so save yourself the trouble and have DBeaver spin one up for you.

Another thing to consider before actually using this tool to help you code is that your table header and column names will be sent to OpenAI to help you code. If you or your org have security concerns about this – you probably can’t use this tool with your job.

So instead, create the sample database so you can use the AI without security concerns.

Installing the ChatGPT Add-on

Click Help > Install New Software

In the “Works with” section, type: “DBeaver” and you should see “DBeaver AI” appear in the section below.

Follow the on-screen prompts and restart DBeaver

Open the sample database and press F3

You should see the OpenAI logo to the left of the SQL editor

Click the ChatGPT logo to launch the API and settings window

Go to your OpenAI account and generate a new key and paste it into the API token field

Click “Apply and Close”

Using the Tool

Click the ChatGPT icon again

You will get a prompt asking permission to read the table header and columns. As mentioned above, if you’re not using the sample database, be sure you’re okay with this before proceeding.

With that, you’re off and running…

ChatGPT Output:

SELECT COUNT(*) FROM Album;

Chat GPT Output:

SELECT Genre.Name, COUNT(InvoiceLine.InvoiceId) AS 'Number of Customers'
FROM Genre
INNER JOIN Track ON Genre.GenreId = Track.GenreId
INNER JOIN InvoiceLine ON Track.TrackId = InvoiceLine.TrackId
GROUP BY Genre.Name
ORDER BY COUNT(InvoiceLine.InvoiceId) DESC;

Troubleshooting

Don’t see the OpenAI icon.

  • If you don’t see the icon, confirm that the editor is allowed to run
    • Click Window > Preferences > Editors > AI (ChatGPT)
  • Ensure that “Enable smart completion” is checked.

Don’t have the DBeaver AI package available to install

  • Ensure the DBeaver is updated
    • Help > Check for Update
  • Manually Add the package
    • Click Help > Install New Software > Add

Leave a Reply

Your email address will not be published. Required fields are marked *