You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
MindSQL: A Python Text-to-SQL RAG Library simplifying database interactions. Seamlessly integrates with PostgreSQL, MySQL, SQLite, Snowflake, and BigQuery. Powered by GPT-4 and Llama 2, it enables natural language queries. Supports ChromaDB and Faiss for context-aware responses.
MindSQL is a Python RAG (Retrieval-Augmented Generation) Library designed to streamline the interaction between users and their databases using just a few lines of code. With seamless integration for renowned databases such as PostgreSQL, MySQL, and SQLite, MindSQL also extends its capabilities to major databases like Snowflake and BigQuery by extending theIDatabase Interface. This library utilizes large language models (LLM) like GPT-4, Llama 2, Google Gemini, and supports knowledge bases like ChromaDB and Faiss.
🚀 Installation
To install MindSQL, you can use pip:
pip install mindsql
MindSQL requires Python 3.10 or higher.
💡 Usage
# !pip install mindsqlfrommindsql.coreimportMindSQLCorefrommindsql.databasesimportSqlitefrommindsql.llmsimportGoogleGenAifrommindsql.vectorstoresimportChromaDB# Add Your Configurationsconfig= {"api_key":"YOUR-API-KEY"}# Choose the Vector Store. LLM and DB You Want to Work With And# Create MindSQLCore Instance With Configured Llm, Vectorstore, And Databaseminds=MindSQLCore(llm=GoogleGenAi(config=config),vectorstore=ChromaDB(),database=Sqlite())# Create a Database Connection Using The Specified URLconnection=minds.database.create_connection(url="YOUR_DATABASE_CONNECTION_URL")# Index All Data Definition Language (DDL) Statements in The Specified Database Into The Vectorstoreminds.index_all_ddls(connection=connection,db_name='NAME_OF_THE_DB')# Index Question-Sql Pair in Bulk From the Specified Example Pathminds.index(bulk=True,path="your-qsn-sql-example.json")# Ask a Question to The Database And Visualize The Resultresponse=minds.ask_db(question="YOUR_QUESTION",connection=connection,visualize=True)# Extract And Display The Chart From The Responsechart=response["chart"]chart.show()# Close The Connection to Your DBconnection.close()
📁 Code Structure
_utils: Utility modules containing constants and a logger.
_helper: The helper module.
core: The main core module,minds_core.py.
databases: Database-related modules.
llms: Modules related to Language Models.
testing: Testing scripts.
vectorstores: Modules related to vector stores.
poetry.lock andpyproject.toml: Poetry dependencies and configuration files.
tests: Testcases.
🤝 Contributing Guidelines
Thank you for considering contributing to our project! Please follow these guidelines for smooth collaboration:
Fork the repository and create your branch from master.
Ensure your code adheres to our coding standards and conventions.
Test your changes thoroughly and add a test case in thetests folder.
Submit a pull request with a clear description of the problem and solution.
We value your feedback and strive to improve MindSQL. Here's how you can share your thoughts with us:
Open an issue to provide general feedback, suggestions, or comments.
Be constructive and specific in your feedback to help us understand your perspective better.
Thank you for your interest in contributing to our project! We appreciate your support and look forward to working with you. 🚀
About
MindSQL: A Python Text-to-SQL RAG Library simplifying database interactions. Seamlessly integrates with PostgreSQL, MySQL, SQLite, Snowflake, and BigQuery. Powered by GPT-4 and Llama 2, it enables natural language queries. Supports ChromaDB and Faiss for context-aware responses.