1280X1280

We are excited to introduce Chat2Query (beta), a revolutionary natural language query generator powered by Pre-trained Transformer 3 (GPT-3), the technology behind ChatGPT, and TiDB, the distributed SQL database.

With Chat2Query, you don’t need to be an SQL expert to extract insights from your data. Simply ask a question and the AI tool will do the rest, generating a powerful SQL query to retrieve the insights. By combining OpenAI and TiDB, we utilize AI to innovate the database and aid in data exploration, providing real-time and actionable insights for instant business decisions.

In this post, we’ll show you how to get started with the AI-powered Chat2Query and explore insights through sample datasets and your own datasets.

More than just another AI-powered SQL generator

Yes, there are several AI-powered SQL generators available that can help users generate SQL queries without needing to have extensive knowledge of the SQL language. However, these AI tools are best suited for generating simple queries. This means they may not be suitable for more complex tasks or production use.

Chat2Query is powered by:

  • OpenAI’s GPT3, the industry-leading natural language-to-code processing model and the technology behind the viral ChatGPT.
  • TiDB Cloud Serverless Tier, the Hybrid Transactional and Analytical Processing (HTAP) database service that enables developers to deploy their infrastructure at scale in the most cost-efficient way without managing server infrastructure.

By using these two technologies, Chat2Query can handle even the most complex queries and offer real-time insights into dynamic datasets.

Exploring sample use cases

In the following examples, we use Chat2Query to generate two queries against different datasets:

Query on the Netflix dataset – tell me the best 10 Netflix titles.

Query on a Web3 dataset – in which month of last year did the highest volumehappen?

Get started with Chat2Query

Chat2Query is an integrated feature in TiDB Cloud Serverless Tier. You can take the following steps to get started:

Step 1: Sign in to your Serverless Tier cluster.

Sign up for a TiDB Cloud account using your email, Google account, or GitHub account. Your Serverless Tier cluster will be created automatically in less than 20 seconds, and you will be directed to the Chat2Query interface.

Step 2: Prepare your datasets.

You can either use the sample datasets to quickly explore Chat2Query or explore insights on your own datasets.

By default, you will query against the sample_data table with four preset datasets – github_events, global_fortune_500, imdb_movie_ratings, and sold_car_orders.

  1. For starters, get your target datasets ready. If you don’t have any, you can get one from free dataset hosting websites such as Kaggle.
  2. Under the Schemas tab, click ... to the right of the target database, and click Import Data to start importing your dataset either in local CSV format or from Amazon S3. In our case, we use eth-usdt, the Ethereum/Tether crypto price dataset in CSV.
  3. Follow the prompts to configure the import source and target and start importing. The time it takes varies depending on the size of the data. When the import is done, the import detail window is displayed.

Step 3: Explore insights with Chat2Query.

  1. Generate the query. In the Chat2Query editor, type in “– your question” and click Enter to let AI generates the query in SQL.
  2. Review the query. Press the Tab key to accept the SQL or edit it as necessary before accepting.
  3. Run your query. In the top right-hand corner of the screen, click the play button. The query results are displayed at the bottom of the page.

You will see the query logs and results immediately at the bottom of the page. For sample output, see Exploring sample uses.

Built with security and privacy

The privacy and security of user data is our top priority. We understand that our users trust us to protect their information and we take that responsibility seriously. As a query service on TiDB Cloud, Chat2Query only needs to access your database schema to generate SQL, and not your actual data.

Limitations

As a beta project, Chat2Query is still in development with a lot of room for improvement. Therefore, there are two limitations to keep in mind:

  1. The AI-generated SQL is not always 100% correct and may still need further tweaking.
  2. Chat2Query has limited support for SQL statements. DDL statements such as CREATE TABLE and DROP TABLE are not supported yet.

Get started withChat2Querytoday

You can obtain early access here. We’d love to hear your feedback so we can make this query tool even better.

In the meantime, Chat2Query is in rapid development. Please follow us on Twitter to stay up-to-date on its progress.


Have a question or comment about the article? Visit the TiDB Forum

Subscribe to Stay Informed!

TiDB Cloud logo-black

TiDB Cloud

Get the massive scale and resiliency of TiDB databases in a fully managed cloud service

TiDB logo-black

TiDB

TiDB is effortlessly scalable, open, and trusted to meet the real-time needs of the digital enterprise