Querying HiveSQL with AI: Goodbye Complex SQLs!

Words
398
Reading
2 min
Listen
Play
2y

Hey there, HiveDevs!

Yesterday I needed to query HiveSQL to get some statistics from PixBee, and I had an idea: why not use AI to create these SQL queries automatically?

The idea came and soon it will no longer be necessary to write complex SQLs to query HiveSQL. With the help of AI, we will be able to ask questions in a more human way and get direct answers.

For example, instead of writing this:

SELECT COUNT(*)
FROM Comments
WHERE author = 'vaipraonde'
AND json_metadata IS NOT NULL
AND json_metadata LIKE '%"hivebr"%'
AND title! = '';

You can simply ask:

!aiquery COUNT how many comments does the user vaipraonde have with json_metadata containing hivebr whose title is not ""?

Or instead of:

SELECT TOP 100 [delegate]
FROM Delegations
WHERE [delegate] IN ('steemskate', 'skatehive');

Simply:

!aiquery lists all delegates for steemskate and skatehive

With the help of mengao@mengao, who already has a bot that queries HiveSQL via Discord, I made a fork, created my HiveSQL account and implemented AI to make searches easier.

After some testing, both with simple queries and with some more complex ones, I managed to get great results.

I believe it will be ready soon! This first version is still a bit "quick and dirty", but I will refactor the code, create more configurations for choosing LLM models, perhaps include more providers and, of course, make the source code available to the community soon.

Here's the spoiler! If you liked the idea, leave a like to encourage me! 馃殌

follow at:
https://github.com/rferrari/HiveSQLDiscordBot


Few examples from tests:

image.png

image.png

image.png



Fala, HiveDevs!

Ontem precisei consultar o HiveSQL para obter algumas estat铆sticas da PixBee, e fiquei me perguntando: por que n茫o usar IA para criar essas queries SQL automaticamente?

A ideia surgiu e logo menos n茫o ser谩 mais necess谩rio escrever SQLs complexas para consultar o HiveSQL. Com a ajuda da IA, poderemos fazer perguntas de forma mais humana e obter respostas diretas.

Por exemplo, em vez de escrever isso:

SELECT COUNT(*)
FROM Comments
WHERE author = 'vaipraonde'
AND json_metadata IS NOT NULL
AND json_metadata LIKE '%"hivebr"%'
AND title != '';

Bastar谩 perguntar:

!aiquery COUNT how many comments user vaipraonde has with json_metadata that contain hivebr that the title is not ""?

Ou em vez de:

SELECT TOP 100 [delegatee]
FROM Delegations
WHERE [delegatee] IN ('steemskate', 'skatehive');

Simplesmente:

!aiquery list all delegatee to steemskate and skatehive

Com a ajuda do mengao@mengao, que j谩 tem um bot que faz consultas no HiveSQL pelo Discord, fiz um fork, criei minha conta no HiveSQL e implementei IA para facilitar as buscas.

Depois de alguns testes, tanto com queries simples quanto com algumas mais complexas, consegui obter 贸timos resultados.

Acredito que logo menos estar谩 pronto! Essa primeira vers茫o ainda est谩 meio "quick and dirty", mas vou refatorar o c贸digo, criar mais configura莽玫es para escolha de modelos LLM, talvez incluir mais providers e, claro, disponibilizar o c贸digo-fonte para a comunidade em breve.

Fica aqui o spoiler! Se curtiu a ideia, deixa um like para me incentivar! 馃殌

follow at:
https://github.com/rferrari/HiveSQLDiscordBot



Querying HiveSQL with AI: Goodbye Complex SQLs! | Ecency