Skip to main content

Multi-Database Smart Query Generator - Convert natural language to SQL using AI

Project description

MDSmart - Multi-Database Smart Query Generator

MDSmart converts natural language questions into SQL using local LLMs via Ollama. It supports SQLite by default, with optional connectors for PostgreSQL and MySQL/MariaDB, plus a built-in FAISS vector store for training examples and a Knowledge Base for injecting business rules and documentation.

Features

  • Local LLMs with Ollama (no external keys required)
  • SQLite, PostgreSQL, and MySQL/MariaDB support with automatic schema extraction (install extras for non-SQLite)
  • Retrieval-augmented prompts using FAISS (examples + knowledge)
  • Retry flow to fix SQL when execution fails

Quick Start

from mdsmart import MDSmart

# Initialize (ensure `ollama serve` is running)
md = MDSmart(model="llama3", embedding_model="nomic-embed-text")

# Connect to database
md.connect_database(
    db_id="sales_db",
    db_type="sqlite",
    connection_params={"path": "sales.db"},
    description="Sales and orders data",
    keywords=["sales", "orders", "revenue"]
)

# Ask a question
result = md.ask("What are the top 10 products by revenue?")
print(result)

Requirements

  • Python 3.8+
  • Ollama installed and running
  • FAISS for vector search (pip install faiss-cpu)

More Documentation

  • Getting Started: docs/getting-started.md
  • API Reference: docs/api.md

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

mdsmart-0.1.0.tar.gz (976.5 kB view details)

Uploaded Source

Built Distribution

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

mdsmart-0.1.0-cp312-cp312-win_amd64.whl (1.7 MB view details)

Uploaded CPython 3.12Windows x86-64

File details

Details for the file mdsmart-0.1.0.tar.gz.

File metadata

  • Download URL: mdsmart-0.1.0.tar.gz
  • Upload date:
  • Size: 976.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for mdsmart-0.1.0.tar.gz
Algorithm Hash digest
SHA256 da388f78aa010961b0470740f49009b3ce6974b214e16f88aa6f466e43dc2d53
MD5 2aa93fb629e2bfa9470c3077e2f53dcd
BLAKE2b-256 51c49ca13daaffb72637d5c9c048545044669768b0e79f479057c15dfaf961cc

See more details on using hashes here.

File details

Details for the file mdsmart-0.1.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: mdsmart-0.1.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 1.7 MB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.4

File hashes

Hashes for mdsmart-0.1.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 961d78d6474b02fae1e7a35b2805ab3dfac9bf74834482ff939e72b89f21c3c3
MD5 df1dd9613a91fedfac6cc069bfb29878
BLAKE2b-256 bf83afc2335184f2d1c53f7f2ca738cb487d923bf32a46aa6fa3b76945749817

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