实现目标:使用自然语言处理我在Bigquery中建立的数据库,并最终将结果用HTML 表格展现出来。
五分钟简易构建,用的第三方付费网站实现Text-to-SQL,调用的API接口,有7天免费试用。目前看来准确率尚可。网站链接:https://www.text2sql.ai/app
首先创建Google Cloud 项目,并创建自己的Bigquery数据库(或者使用公开数据库)
1. setup
# @title Setup
from google.colab import auth
from google.cloud import bigquery
from google.colab import data_table
import requests
import json
import pandas as pd
project = '**********' # 你的project ID
location = 'US' # Location inserted based on the query results selected to explore
client = bigquery.Client(project=project, location=location)
data_table.enable_dataframe_formatter()
auth.authenticate_user()
2. 调用API,获取SQL查询语句
#输入你想实现的命令