Querying Databases with OpenAI

Querying Databases with OpenAI: My Experience with Marcel Pociot’s Package

Hello everyone! In this post, I want to share my experience with Marcel Pociot’s new package for querying databases with OpenAI. This package allows you to query your database using natural language instead of SQL queries, which can be a game-changer for those who are not familiar with SQL. However, it’s important to note that using AI is not free, and I will discuss the cost implications later in this post. So, let’s dive into my experience with this package!

Installing the Package

Installing this package is very easy. All you need to do is to run “composer require” and “vendor publish” commands to choose the OpenAI service provider. Then, you can configure the OpenAI settings in the Laravel repository. Once you have everything set up, you can start querying your database using natural language.

My Experience with Querying the Database

I used Tinkeril, a tool by Beyond Code, to test the package. I asked the database how many users we have with an email ending in “.net”. The package returned the actual query and the result, which was 43 users out of 110. I was fascinated by how easy it was to query the database using natural language.

The Cost of Using OpenAI

It’s important to note that using OpenAI is not free. OpenAI provides a free credit of $18, but running a few queries can quickly add up. For my usage, running a few queries cost $0.05. If you use OpenAI heavily, it can cost you quite a lot. So, it’s important to be careful when using OpenAI.

Who Would Use This Package?

This package can be useful for non-technical people who want to query the database without knowing SQL. For example, managers who want to get reports can use this package to query the database using natural language. However, it may not be reliable for more complex queries. It’s important to note that the package restricts certain security-related queries by default, such as “Insert,” “Delete,” and “Update.”

Conclusion:

Overall, my experience with Marcel Pociot’s package for querying databases with OpenAI was positive. It’s an easy-to-use package that can be helpful for non-technical people who want to query the database using natural language. However, it’s important to note the cost implications of using OpenAI and the limitations of the package. What do you think about using AI to query databases? Let’s discuss in the comments!

Leave a Reply

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