All Projects → abhijithneilabraham → Tableqa

abhijithneilabraham / Tableqa

Licence: gpl-3.0
AI Tool for querying natural language on tabular data.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Tableqa

Jet
Type safe SQL builder with code generation and automatic query result data mapping
Stars: ✭ 373 (+242.2%)
Mutual labels:  sql, sql-query, database
Finviz
Unofficial API for finviz.com
Stars: ✭ 493 (+352.29%)
Mutual labels:  csv, sql, database
Dataux
Federated mysql compatible proxy to elasticsearch, mongo, cassandra, big-table, google datastore
Stars: ✭ 268 (+145.87%)
Mutual labels:  sql, sql-query, database
Querybuilder
SQL query builder, written in c#, helps you build complex queries easily, supports SqlServer, MySql, PostgreSql, Oracle, Sqlite and Firebird
Stars: ✭ 2,111 (+1836.7%)
Mutual labels:  sql, sql-query, database
Squid
🦑 Provides SQL tagged template strings and schema definition functions.
Stars: ✭ 57 (-47.71%)
Mutual labels:  sql, sql-query, database
Chat
基于自然语言理解与机器学习的聊天机器人,支持多用户并发及自定义多轮对话
Stars: ✭ 516 (+373.39%)
Mutual labels:  question-answering, database, qa
Jooq
jOOQ is the best way to write SQL in Java
Stars: ✭ 4,695 (+4207.34%)
Mutual labels:  sql, sql-query, database
Deveeldb
DeveelDB is a complete SQL database system, primarly developed for .NET/Mono frameworks
Stars: ✭ 80 (-26.61%)
Mutual labels:  sql, sql-query, database
Goqu
SQL builder and query library for golang
Stars: ✭ 984 (+802.75%)
Mutual labels:  sql, sql-query, database
Nano Sql
Universal database layer for the client, server & mobile devices. It's like Lego for databases.
Stars: ✭ 717 (+557.8%)
Mutual labels:  csv, sql, database
Reporting Services Examples
📕 Various example reports I use for SQL Server Reporting Services (SSRS) as well as documents for unit testing, requirements and a style guide template.
Stars: ✭ 63 (-42.2%)
Mutual labels:  sql, sql-query, database
Postguard
🐛 Statically validate Postgres SQL queries in JS / TS code and derive schemas.
Stars: ✭ 104 (-4.59%)
Mutual labels:  sql, sql-query, database
Electrocrud
Database CRUD Application Built on Electron | MySQL, Postgres, SQLite
Stars: ✭ 1,267 (+1062.39%)
Mutual labels:  sql, database
Dbwebapi
(Migrated from CodePlex) DbWebApi is a .Net library that implement an entirely generic Web API (RESTful) for HTTP clients to call database (Oracle & SQL Server) stored procedures or functions in a managed way out-of-the-box without any configuration or coding.
Stars: ✭ 84 (-22.94%)
Mutual labels:  csv, database
Filecontextcore
FileContextCore is a "Database"-Provider for Entity Framework Core and adds the ability to store information in files instead of being limited to databases.
Stars: ✭ 91 (-16.51%)
Mutual labels:  csv, database
Toydb
Distributed SQL database in Rust, written as a learning project
Stars: ✭ 1,329 (+1119.27%)
Mutual labels:  sql, database
Graphjin
GraphJin - Build APIs in 5 minutes with GraphQL. An instant GraphQL to SQL compiler.
Stars: ✭ 1,264 (+1059.63%)
Mutual labels:  sql, database
Qtl
A friendly and lightweight C++ database library for MySQL, PostgreSQL, SQLite and ODBC.
Stars: ✭ 92 (-15.6%)
Mutual labels:  sql, database
Happy Transformer
A package built on top of Hugging Face's transformer library that makes it easy to utilize state-of-the-art NLP models
Stars: ✭ 97 (-11.01%)
Mutual labels:  ai, question-answering
Lol dba
lol_dba is a small package of rake tasks that scan your application models and displays a list of columns that probably should be indexed. Also, it can generate .sql migration scripts.
Stars: ✭ 1,363 (+1150.46%)
Mutual labels:  sql, database

tableQA

AI Tool for querying natural language on tabular data.Built using QA models from transformers.

Here is a detailed blog to understand how this works.

A tabular data can be:

  • Dataframes
  • CSV files

Build Status Open In Colab

Features

  • Supports detection from multiple csvs (csvs can also be read from Amazon s3)
  • Supports FuzzyString implementation. i.e, incomplete column values in query can be automatically detected and filled in the query.
  • Supports Databases - SQLite, Postgresql, MySQL, Amazon RDS (Postgresql, MySQL).
  • Open-Domain, No training required.
  • Add manual schema for customized experience
  • Auto-generate schemas in case schema not provided
  • Data visualisations.

Supported operations.

  • [X] SELECT
    • [X] one column
    • [X] multiple columns
    • [X] all columns
    • [X] aggregate functions
    • [X] distinct select
      • [X] count-select
      • [X] sum-select
      • [X] avg-select
      • [X] min-select
      • [X] max-select
  • [X] WHERE
    • [X] one condition
    • [X] multiple conditions
    • [X] operators
      • [X] equal operator
      • [X] greater-than operator
      • [X] less-than operator
      • [X] between operator

Configuration:

install via pip:

pip install tableqa

installing from source:

git clone https://github.com/abhijithneilabraham/tableQA

cd tableqa

python setup.py install

Quickstart

Do sample query

from tableqa.agent import Agent
agent=Agent(df) #input your dataframe
response=agent.query_db("Your question here")
print(response)

Get an SQL query from the question

sql=agent.get_query("Your question here")  
print(sql) #returns an sql query

Adding Manual schema

Schema Format:
{
    "name": DATABASE NAME,
    "keywords":[DATABASE KEYWORDS],
    "columns":
    [
        {
        "name": COLUMN 1 NAME,
        "mapping":{
            CATEGORY 1: [CATEGORY 1 KEYWORDS],
            CATEGORY 2: [CATEGORY 2 KEYWORDS]
        }

        },
        {
        "name": COLUMN 2 NAME,
        "keywords": [COLUMN 2 KEYWORDS]
        },
        {
        "name": "COLUMN 3 NAME",
        "keywords": [COLUMN 3 KEYWORDS],
        "summable":"True"
        }
    ]
}

  • Mappings are for those columns whose values have only few distinct classes.
  • Include only the column names which need to have manual keywords or mappings.Rest will will be autogenerated.
  • summable is included for Numeric Type columns whose values are already count representations. Eg. Death Count,Cases etc. consists values which already represent a count.

Example (with manual schema):

Database query
  • Default Database - SQLite (File-based database, does not require creation of a separate connection.)
from tableqa.agent import Agent
agent=Agent(df,schema) #pass the dataframe and schema objects
response=agent.query_db("how many people died of stomach cancer in 2011")
print(response)
#Response =[(22,)]
  • To use PostgreSQL, you must have a postgresql server installed and running on your local. To download postgresql, visit the page.
from tableqa.agent import Agent
agent = Agent(df, schema_file, 'postgres', username='username', password='password', database='DBname', host='localhost', port=5432, aws_db=False)
response=agent.query_db("how many people died of stomach cancer in 2011")
print(response)
#Response =[(22,)]
  • To use MySQL, you must have a mysql server installed and running on your local. To download mysql, visit the page.
from tableqa.agent import Agent
agent = Agent(df, schema_file, 'mysql', username='username', password='password', database='DBname', host='localhost', port=5432, aws_db=False)
response=agent.query_db("how many people died of stomach cancer in 2011")
print(response)
#Response =[(22,)]

  • To use PostgreSQL or MySQL on Amazon RDS, you must create a database on Amazon RDS. The RDS must be in public subnet with security groups allowing connections from outside of AWS.

Refer to step 1 in the document to create a mysql db instance on Amazon RDS. Same steps can be followed for creating a PostgreSQL db instance by selecting PostgreSQL in the Engine tab. Obtain the username, password, database, endpoint, and port from your database connection details on Amazon RDS.

from tableqa.agent import Agent
agent = Agent(df, schema_file, 'postgres', username='Master username', password='Master password', database='DB name', host='Endpoint', port='Port', aws_db=True)
response=agent.query_db("how many people died of stomach cancer in 2011")
print(response)
#Response =[(22,)]

SQL query
sql=agent.get_query("How many people died of stomach cancer in 2011")
print(sql)
#sql query: SELECT SUM(Death_Count) FROM cancer_death WHERE Cancer_site = "Stomach" AND Year = "2011"

Multiple CSVs

  • Pass the absolute path of the directories containing the csvs and schemas respectively. Refer cleaned_data and schema for examples.
Example
  • Read CSV and Schema from local machine-
csv_path="/content/tableQA/tableqa/cleaned_data"
schema_path="/content/tableQA/tableqa/schema"
agent=Agent(csv_path,schema_path)

  • Read CSV and schema files from Amazon s3 -
  1. Create a bucket on Amazon s3.
  2. Upload objects to the bucket.
  3. Create an IAM user and provide it access to read files from Amazon s3 storage.
  4. Obtain the access key and secret access key for the user and pass it as an argument to the agent.
csv_path="s3://{bucket}/cleaned_data"
schema_path="s3://{bucket}/schema"
agent = Agent(csv_path, schema_path, aws_s3=True, access_key_id=access_key_id, secret_access_key=secret_access_key)

Join us

Join our workspace:Slack

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].