Skip to main content

AI-Text-to-SQL, revolutionize database querying with AI-powered text-to-SQL.

Project description

AI-Text-to-SQL: Transforming Text Queries into SQL Magic ✨

Have you ever wished you could simply speak or type your queries in plain English, and poof! They magically turn into perfectly formatted SQL queries? Well, say hello to AI-Text-to-SQL - the enchanting Python package that brings your dream to life!

Unleashing the Magic 🌟

With pip

Installing AI-Text-to-SQL is as easy as pip-pip-pip:

pip install ai_text_to_sql

Casting the Spell: AI-Text-to-SQL in Action 🎩✨

To summon the power of AI-Text-to-SQL, follow these mystical steps and witness the enchantment unfold!

Step 1: Prepare Your Spell Ingredients 🌟

Begin by importing the essential components for your SQL sorcery:

  • Import the Data Connector: Choose the right data connector, like selecting the perfect wand for your SQL spellcasting.
  • Import the LLM Connector: This vital ingredient enhances the mystical abilities of ai_text_to_sql, enabling it to comprehend your text queries like a seasoned SQL wizard.

Let's summon the SQLite and OpenAI connectors to embark on our magical SQL adventure:

from ai_text_to_sql.data_connectors import SQLiteConnector
from ai_text_to_sql.llm_connectors import OpenAIConnector

Now, define the magical incantation you wish to transform into SQL:

text_query = "Find all the tracks written by AC/DC, including the track name, album " \
             "title and the artist name. Sort the results alphabetically by track name."

Step 2: Choose Your Path of Power 🌟

🧙‍♂️ Conjuring the Core SQL Spell with TextToSQL

For those who seek to transform text into SQL queries with pure magic, invoke TextToSQL:

from ai_text_to_sql import TextToSQL

sqlite_connector = SQLiteConnector(database='chinook.db')
openai_connector = OpenAIConnector(api_key='YOUR_OPENAI_API_KEY')

text_to_sql = TextToSQL(sqlite_connector, openai_connector)

# Witness the spell's transformation 🔮✨
sql_query = text_to_sql.convert_text_to_sql(text_query)

# Unleash the magic upon the database directly 💾✨
results = text_to_sql.query(text_query)

# Store the results in a DataFrame for further sorcery 📊✨
df = text_to_sql.query_df(text_query)

🧙‍♀️ Summoning the Enchanted Conversationalist with TextToSQLChat (New!)

For those who desire the power of TextToSQL but with memory, TextToSQLChat allows ongoing dialogue with your SQL queries:

from ai_text_to_sql import TextToSQLChat

text_to_sql = TextToSQLChat(sqlite_connector, openai_connector)

# Begin the conversation with the initial query 🗣️✨
results = text_to_sql.query(text_query)
# OR
df = text_to_sql.query_df(text_query)

# Continue the dialogue with a follow-up query 🗣️✨
follow_up_query = "OK, now let's do Queen"

follow_up_results = text_to_sql.query(follow_up_query)
# OR
follow_up_df = text_to_sql.query_df(follow_up_query)

🌯 Unlocking Advanced Sorcery with TextToSQLAgent (New!)

For those who seek a fully autonomous SQL assistant, TextToSQLAgent orchestrates multi-step reasoning, follow-ups, and intelligent query crafting:

from ai_text_to_sql import TextToSQLAgent

text_to_sql_agent = TextToSQLAgent(sqlite_connector, openai_connector)

# Engage the AI agent in a conversation 🤖✨
response = text_to_sql_agent.query(text_query)

# Continue the dialogue with a follow-up query 🤖✨
follow_up_query = "OK, now let's do Led Zeppelin"
follow_up_response = text_to_sql_agent.query(follow_up_query)

With these powerful artifacts at your disposal, you are now equipped to master the arcane arts of AI-driven SQL spellcasting! 🌟🎉

The Realm of Compatible Databases 🌐🏰

Within the enchanted realm of AI-Text-to-SQL, a variety of databases stand ready to be harmoniously united with your mystical text queries. Our sorcery extends its reach to the following realms of data:

Database Status
SQLite
PostgreSQL
MySQL
MariaDB
MS SQLServer
Oracle 🔜
MS Access 🔜
Firebird 🔜
IBM Db2 🔜

Is your preferred database missing from the list? Don't worry! Suggestions for new data connectors are always welcome. Feel free to create an issue on the GitHub repository and maybe even submit a pull request!

The Fellowship of Language Learning Models 🧠📚

In the mystical realm of AI-Text-to-SQL, an esteemed fellowship of Language Learning Models (LLMs) awaits to join forces with your magical text queries. Our sorcery encompasses the wisdom of the following LLM allies:

LLM Status
OpenAI
Bard 🔜
HuggingFace 🔜

Excited about the potential of additional LLMs? If you have recommendations for new LLM connectors to integrate into AI-Text-to-SQL, please create an issue on the GitHub repository to share your ideas and take steps to contribute to the project!

Contributing 🤝

Thank you for your interest in contributing to AI-Text-to-SQL! Contributions from the community are highly appreciated.

For detailed instructions on how to contribute to the project, please refer to the CONTRIBUTING.md file. It provides guidelines on reporting bugs, suggesting new features, making code improvements, and more.

Your contributions are valuable, and together, let's collaborate to enhance AI-Text-to-SQL and make it even more magical!

License 📜

AI-Text-to-SQL is released under the GNU General Public License v3.0 (GPL-3.0). This means that you are free to use, modify, and distribute this package in compliance with the terms outlined in the license.

Embrace the spirit of open-source collaboration and together let's propel the world of text-to-SQL transformation forward!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ai_text_to_sql-0.3.0.tar.gz (25.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ai_text_to_sql-0.3.0-py3-none-any.whl (30.6 kB view details)

Uploaded Python 3

File details

Details for the file ai_text_to_sql-0.3.0.tar.gz.

File metadata

  • Download URL: ai_text_to_sql-0.3.0.tar.gz
  • Upload date:
  • Size: 25.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for ai_text_to_sql-0.3.0.tar.gz
Algorithm Hash digest
SHA256 09020065bbd705fb3b1de75df67d657c99027fdc3c4a4edb1b8a18cc3321daa3
MD5 f3f3516e14f7f2ea1ffccd6ec4fc0153
BLAKE2b-256 f2b20d8654063d647ecb23d3b507cfe6d4f69c393be7681c36516fba3196cb54

See more details on using hashes here.

File details

Details for the file ai_text_to_sql-0.3.0-py3-none-any.whl.

File metadata

  • Download URL: ai_text_to_sql-0.3.0-py3-none-any.whl
  • Upload date:
  • Size: 30.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.8

File hashes

Hashes for ai_text_to_sql-0.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 124d786ab33b4b4599847ba64958b13bf70000cc261414b708cfca90b6e878f9
MD5 d967b19e46cf8688b3332bb49e836d60
BLAKE2b-256 99e81c0f144f22d5e6f732ec7b666ea7c57818876942513262902da7152320af

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page