Skip to main content

A new package enables AI systems to securely interact with MySQL databases by translating natural language queries into structured SQL commands. It processes user text input to generate safe, validate

Project description

ai-mysql-translator

PyPI version License: MIT Downloads LinkedIn

Overview

A package enables AI systems to securely interact with MySQL databases by translating natural language queries into structured SQL commands. It processes user text input to generate safe, validated database operations, ensuring responses are consistent and free from injection risks. This allows AI assistants to perform data retrieval and manipulation without exposing sensitive database structures or requiring manual query writing.

Installation

pip install ai_mysql_translator

Usage

from ai_mysql_translator import ai_mysql_translator
user_input: str
api_key: Optional[str] = None
llm: Optional[BaseChatModel] = None

response = ai_mysql_translator(
    user_input, 
    api_key=api_key, 
    llm=llm 
)

You can safely pass your own llm instance (based on https://docs.langchain.com/) if you prefer to use a different LLM. For example, to use the OpenAI LLM, you can use:

from langchain_openai import ChatOpenAI
import ai_mysql_translator

llm = ChatOpenAI()
response = ai_mysql_translator(
    user_input,
    llm=llm
)

Or to use the Anthropic LLM, you can use:

from langchain_anthropic import ChatAnthropic
import ai_mysql_translator

llm = ChatAnthropic()
response = ai_mysql_translator(
    user_input,
    llm=llm
)

Or Google Generative AI LLM, use:

from langchain_google_genai import ChatGoogleGenerativeAI
import ai_mysql_translator

llm = ChatGoogleGenerativeAI()
response = ai_mysql_translator(
    user_input,
    llm=llm
)

The package uses the ChatLLM7 from langchain_llm7 (https://pypi.org/project/langchain-llm7/) by default.

If you need higher rate limits for LLM7, you can pass your own API key via environment variable LLM7_API_KEY or directly via api_key. You can obtain a free API key by registering at https://token.llm7.io/.

GitHub

Author

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_mysql_translator-2025.12.21101721.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

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

File details

Details for the file ai_mysql_translator-2025.12.21101721.tar.gz.

File metadata

File hashes

Hashes for ai_mysql_translator-2025.12.21101721.tar.gz
Algorithm Hash digest
SHA256 adf75f05539b324fd0d56ff5d0ebb0767d550adfcdf15bece059c0365659f4d5
MD5 092eb844d44884229ef0e9e1a456e3e9
BLAKE2b-256 7715149ce95f6c0d2e9ce9b0ea29619f448dcc43ccc8697ec99ba058ef6f3c25

See more details on using hashes here.

File details

Details for the file ai_mysql_translator-2025.12.21101721-py3-none-any.whl.

File metadata

File hashes

Hashes for ai_mysql_translator-2025.12.21101721-py3-none-any.whl
Algorithm Hash digest
SHA256 6c4a0709f6ac6c370d9dc370fa293f685a9da2c74948af9580f13a11671eb583
MD5 baf66a2f197314faf2b34ccd5e94e1e5
BLAKE2b-256 e9eb7217d46653b1a874a1cc5cd4dbde7e9a9c7e9662acf4018b6321ba6b2e9e

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