Skip to content

Conversation

@CroWzblooD
Copy link

@CroWzblooD CroWzblooD commented Oct 20, 2025

Add MariaDB Integration with Native VECTOR Support

This PR adds MariaDB database and vector store integration to MindSQL with native VECTOR(384) data type support.

What's Added

MariaDB Database Connector (mindsql/databases/mariadb.py)

  • Uses official mariadb Python connector
  • Works with MariaDB 11.7+ (includes VECTOR support)
  • Handles schema discovery and DDL extraction
  • Connection management with proper error handling

MariaDB Vector Store (mindsql/vectorstores/mariadb_vector.py)

  • Native VECTOR(384) data type support - no JSON serialization needed
  • FULLTEXT indexing for hybrid search (combines vector similarity with keyword search)
  • Stores data and vectors in the same database
  • ACID compliant with transaction support

What's Modified

Constants (mindsql/_utils/constants.py)

  • Added MariaDB-specific query constants for database introspection
  • SHOW DATABASES, table info schema, and CREATE TABLE queries

Helper Functions (mindsql/_helper/helper.py)

  • Improved SQL extraction to handle different LLM response formats
  • Better parsing of SQLQuery labels and code blocks

Core Pipeline (mindsql/core/mindsql_core.py)

  • Enhanced DDL retrieval with fallback logic
  • Tries vector search first, falls back to full schema if needed

Module Exports (mindsql/databases/__init__.py and mindsql/vectorstores/__init__.py)

  • Added MariaDB and MariaDBVectorStore to public API

Architecture

Screenshot 2025-10-11 000201

Usage Example

from mindsql.core import MindSQLCore
from mindsql.databases import MariaDB
from mindsql.vectorstores import MariaDBVectorStore
from mindsql.llms import GoogleGenAi

# Setup
database = MariaDB()
vectorstore = MariaDBVectorStore(config={
    'host': 'localhost',
    'port': 3306,
    'user': 'root',
    'password': 'password',
    'database': 'mydb'
})
llm = GoogleGenAi(config={'api_key': 'your-key'})

mindsql = MindSQLCore(database=database, vectorstore=vectorstore, llm=llm)

# Connect and query
connection = database.create_connection('mariadb://user:pass@localhost:3306/mydb')
tables = database.get_table_names(connection, 'mydb')['table_name'].tolist()

# Ask questions in natural language
sql = mindsql.create_database_query(
    question="Show me customers who ordered this month",
    connection=connection,
    tables=tables
)
results = database.execute_sql(connection, sql)

@CroWzblooD CroWzblooD changed the title Add MariaDB integration with native VECTOR(384) support Add MariaDB integration with native MariaDB VECTOR support Oct 22, 2025
@CroWzblooD CroWzblooD force-pushed the mariadb-integration-pr branch from c810b9f to 070d1b5 Compare October 31, 2025 08:22
CroWzblooD pushed a commit to CroWzblooD/MindSQL that referenced this pull request Oct 31, 2025
- Add comprehensive README with hackathon links and submission details
- Update LICENSE to MIT (2025)
- Add simplified CONTRIBUTING for hackathon showcase
- Update CODE_OF_CONDUCT.md to Contributor Covenant 2.0
- Add SECURITY.md with reporting guidelines

This is showcase documentation for the MariaDB Python Hackathon 2024 submission.
Main contribution is via PR Mindinventory#34 to original MindSQL repository.
@CroWzblooD CroWzblooD force-pushed the mariadb-integration-pr branch from cf9bcd0 to 6eb0403 Compare November 1, 2025 05:35
Implement MariaDB database connector and vector store with native VECTOR(384) data type support for efficient similarity search. Includes improvements to SQL extraction and DDL retrieval.
@CroWzblooD CroWzblooD force-pushed the mariadb-integration-pr branch from 6eb0403 to 2c2faae Compare November 1, 2025 06:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant