Skip to main content

A security-first in mind and at design, natural language Python package and interface for querying large relational databases. Supports MySQL, PostgreSQL, and SQLite.

Project description

Query Mate: Chat With Your Database

TL, DR: A Secure Text-to-SQL System for Large Relational Databases.

Most agentic AI frameworks, such as LlamaIndex, CrewAI, and LangChain, provide natural language querying capabilities via or help of tools calls, that translate questions into SQL and return responses in human-readable formats. However, these frameworks also leave room for a series of gaps that require urgent, meticulous, and painstaking solutions. They are not designed with security in mind, at heart, or at their core — and relational database systems contain sensitive information that must be protected, with rigorous security measures applied accordingly.

The goal here is to develop an intelligent database querying system that is secure-first in mind, in core, and in design — one that enables users, most especially non-technical users such as stakeholders, to interact with their relational databases using natural language instead of SQL syntax. This stands in contrast to most of the aforementioned agentic AI frameworks, whose 'one' or 'some' of their capabilities are primarily designed for developers, excluding stakeholders entirely, while also lacking security. Here, handling of databases with a large number of tables, as well as security concerns and credential protection measures, are enforced and highly considered throughout this project's implementation.

High-Level System Design

QueryMate

Core Functionality

The system provides a natural language interface for querying relational databases through the following workflow:

  • Database Connection: Users establish a read-only connection to their database.
  • Natural Language Input: Users submit questions in plain english.
  • SQL Translation: The LLM converts the natural language question into a valid SQL query.
  • Query Execution: The generated SQL query retrieves requested information from the database
  • Response Generation: The LLM transforms the database results into a natural language response
  • User Display: The formatted answer is presented to the user through a web interface

Supported Databases

Currently, this package only provides support for three relational database management systems (RDBMS). They are:

  • PostgreSQL
  • SQLite
  • MySQL

Key Components

  • LLM Integration: Natural language processing for query translation and response generation
  • Database Schema Understanding: Object-Relational Mapping (ORM) to enable the LLM to comprehend database structure, relationships, and constraints
  • Agents: Intelligent agent for query generation, validation and human readable responses generation
  • Web User Interface: Browser-based interface for user interaction
  • Read-Only Access Control: Security enforcement to prevent data modification
  • Guardrails: Security enforcement to prevent data modification

System Architecture

This system operates or functions as an AI-assisted database agent that:

  • Maintains comprehensive knowledge of the connected database schema through ORM
  • Translates natural language to SQL with contextual understanding
  • Executes queries safely with read-only permissions
  • Provides human-friendly explanations of query results

Use Cases

  • Non-technical users (Stakeholders) querying databases without SQL knowledge
  • Rapid data exploration and analysis
  • Business intelligence and reporting through conversational interface
  • Database documentation and understanding through natural language queries

Security Considerations

  • Enforced read-only database access
  • Query validation before execution
  • No data modification capabilities
  • Secure database credential handling: Ensure that database credentials are collected securely.

all tests

uv run pytest tests/ -v

only the package tests

uv run pytest tests/querymate/ -v

only the API tests

uv run pytest tests/api/ -v

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

querymate_sdk-0.1.0.tar.gz (30.9 kB view details)

Uploaded Source

Built Distribution

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

querymate_sdk-0.1.0-py3-none-any.whl (38.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: querymate_sdk-0.1.0.tar.gz
  • Upload date:
  • Size: 30.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Zorin OS","version":"17","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for querymate_sdk-0.1.0.tar.gz
Algorithm Hash digest
SHA256 94ae1362b36e26b2eedda98738f41409afdc48a35b8077cd7da625148b820c09
MD5 3918b42e20725b85de98b9f8060846ff
BLAKE2b-256 fa35aac8bd233e4f50fc94dee872f00ba8e57180ec0c4cb966d9d48b8e57785b

See more details on using hashes here.

File details

Details for the file querymate_sdk-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: querymate_sdk-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 38.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.9.21 {"installer":{"name":"uv","version":"0.9.21","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Zorin OS","version":"17","id":"jammy","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

File hashes

Hashes for querymate_sdk-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 47f171b77c82ddc9792d1679eac7dc7c127d54e3285c30c4d615f762b585e3ca
MD5 7b891a88650bf756bf33413cade47e0c
BLAKE2b-256 01433fe0a27392e38ad7da78265a9d906ee438a09c40df2ea143c1c4f8846ba8

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