A Streamlit-based chat interface for analyzing database schemas using LangChain and GPT-4. This tool helps developers and database administrators explore and understand database schemas through natural language conversations.
- Interactive chat interface for database schema analysis
- Support for PostgreSQL and MySQL databases
- Maintains conversation context across queries
- Real-time SQL query execution and explanation
- Secure credential handling
- Comprehensive schema inspection capabilities
- Python 3.11 or higher
- OpenAI API key
- Access to a PostgreSQL or MySQL database
-
Clone the repository:
git clone https://github.com/BLTGV/schema-chat.git cd schema-chat
-
Create and activate a virtual environment:
python -m venv venv source venv/bin/activate # On Unix/MacOS # or venv\Scripts\activate # On Windows
-
Install required packages:
pip install -r requirements.txt
-
Set up environment variables:
cp .env.example .env
Edit
.env
and add your OpenAI API key.
-
Start the application:
streamlit run app.py
-
In the sidebar, enter your database connection details:
- Select database type (PostgreSQL/MySQL)
- Enter host, port, database name
- Provide username and password
-
Click "Connect" to establish the database connection
-
Start chatting with the AI about your database schema!
- "List all tables in the database"
- "Describe the structure of the users table"
- "What foreign key relationships exist?"
- "Show me the indexes on the orders table"
- "Explain the relationship between customers and orders"
- Database credentials are only stored in memory during the session
- The .env file containing your OpenAI API key should never be committed to version control
- Use appropriate database user permissions
Contributions are welcome! Please feel free to submit a Pull Request.
This project is licensed under the MIT License - see the LICENSE file for details.