ollama postgresql data analysis.com
ollama postgresql data analysis.com logo

Ollama PostgreSQL Data Analysis

Integrates natural language querying with PostgreSQL databases to enable AI-interpreted data analysis without manual SQL...

Created byApr 22, 2025

Ollama MCP Database Assistant

An interactive chat interface that combines Ollama's LLM capabilities with PostgreSQL database access through the Model Context Protocol (MCP). Ask questions about your data in natural language and get AI-powered responses backed by real SQL queries.

Features

  • Natural language interface to your PostgreSQL database
  • Automatic SQL query generation
  • Schema-aware responses
  • Interactive chat interface
  • Secure, read-only database access

Prerequisites

  • Node.js 16 or higher
  • A running PostgreSQL database
  • Ollama installed and running locally
  • The qwen2.5-coder:7b-instruct model pulled in Ollama

Setup

  1. Clone the repository:
  1. Install dependencies:
  1. Pull the required Ollama model:
  1. Create a .env file in the project root:

Usage

  1. Start the chat interface:
  1. Ask questions about your data in natural language:
  1. Type 'exit' to quit the application.

How It Works

  1. The application connects to your PostgreSQL database through the PostgreSQL MCP server
  1. It loads and caches your database schema
  1. When you ask a question:

Environment Variables

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Security

  • All database access is read-only
  • SQL queries are restricted to SELECT statements
  • Database credentials are kept secure in your .env file

Development

Built with:
  • TypeScript
  • Model Context Protocol (MCP)
  • Ollama
  • PostgreSQL

Troubleshooting

Common Issues

  1. "Failed to connect to database"
  1. "Failed to connect to Ollama"
  1. "Error executing query"

License

MIT

Contributing

  1. Fork the repository
  1. Create your feature branch
  1. Commit your changes
  1. Push to the branch
  1. Open a Pull Request

Ollama MCP Database Assistant

An interactive chat interface that combines Ollama's LLM capabilities with PostgreSQL database access through the Model Context Protocol (MCP). Ask questions about your data in natural language and get AI-powered responses backed by real SQL queries.

Features

  • Natural language interface to your PostgreSQL database
  • Automatic SQL query generation
  • Schema-aware responses
  • Interactive chat interface
  • Secure, read-only database access

Prerequisites

  • Node.js 16 or higher
  • A running PostgreSQL database
  • Ollama installed and running locally
  • The qwen2.5-coder:7b-instruct model pulled in Ollama

Setup

  1. Clone the repository:
  1. Install dependencies:
  1. Pull the required Ollama model:
  1. Create a .env file in the project root:

Usage

  1. Start the chat interface:
  1. Ask questions about your data in natural language:
  1. Type 'exit' to quit the application.

How It Works

  1. The application connects to your PostgreSQL database through the PostgreSQL MCP server
  1. It loads and caches your database schema
  1. When you ask a question:

Environment Variables

[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]
[object Object]

Security

  • All database access is read-only
  • SQL queries are restricted to SELECT statements
  • Database credentials are kept secure in your .env file

Development

Built with:
  • TypeScript
  • Model Context Protocol (MCP)
  • Ollama
  • PostgreSQL

Troubleshooting

Common Issues

  1. "Failed to connect to database"
  1. "Failed to connect to Ollama"
  1. "Error executing query"

License

MIT

Contributing

  1. Fork the repository
  1. Create your feature branch
  1. Commit your changes
  1. Push to the branch
  1. Open a Pull Request