Skip to main content

Natural Language Query Counting

Overview

AskTable provides an API interface for generating SQL from natural language queries and directly returning the query results. With this API, developers can leverage AskTable's natural language processing capabilities to quickly retrieve information from databases. This is particularly suitable for scenarios that require simplifying the query process and improving development efficiency.

Applicable Scenarios

  1. Developers want users to be able to directly obtain data through natural language queries without having to handle the generation and execution of SQL statements themselves.
  2. Developers do not want to use AskTable's UI interface and instead wish to implement their own UI interface to directly display the query results.
  3. Developers want to provide flexible querying methods suitable for various user scenarios.

Python SDK Example

If you are a Python developer, you can directly use the Python SDK to query, which is very convenient. The specific example code is as follows:

# Example code for generating answers:
from asktable import Asktable

api_key = "<ASKTABLE_API_KEY>"
asktable_client = Asktable(api_key=api_key)

datasource_id = "ds_4cwCIrEBpLM5lkWlysW"
question = "How many orders are there today?"
answer_response = asktable_client.answers.create(datasource_id=datasource_id, question=question)

print(answer_response.answer.text)

Summary

Through the natural language query counting API provided by AskTable, users can easily obtain the required information from the database without writing complex SQL queries. This approach not only simplifies the query process but also ensures the accuracy and timeliness of the data, making it suitable for various scenarios requiring quick data retrieval.

For more questions about API usage, please visit AskTable Documentation for detailed information.