Search code examples
openai-api

SQL to Text Tools


There are a lot of text-to-sql translators out there (langchain for example), are there any sql-to-text translators?

I'd like to be able to feed in a random sql snippet as well as the sql varient (postgres, oracle, t-sql etc.) and see an explanation.

For example, given select count(*) from baseball_players postgres I'd like to see something like

Count the number of baseball players in MLB today

I've looked at langchain, and hugging face with no luck. Here's an example of a website that is doing what I'm describing.

https://www.text2sql.ai/


Solution

  • I am assuming that you don't want an arbitrarily terse explanation, but a "plain language" explanation. I know current chatGPT is capable of this as well (but it's currently blocked from where I am). So here is an example from BingAI:

    "could you please describe what this does: select count()::numeric from baseball_players*"

    response:

    Sure! The given statement is a SQL query that counts the total number of rows in the baseball_players table and returns the result as a numeric value. The ::numeric part of the query casts the result of count() to a numeric data type.* Is there anything else you would like to know?

    note I placed postgres specific syntax into the query