postgres-query

Execute SQL statements in PostgreSQL containers via automatic container detection.

1|Updated Jan 2, 2026
One-click install
npx skills add https://github.com/racar/racar_agent_skills --skill postgres-query
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgres-query
Source: https://github.com/racar/racar_agent_skills/tree/main/skills/postgres-query
Command: npx skills add https://github.com/racar/racar_agent_skills --skill postgres-query

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires docker, psql, and includes scripts (resource) and references (resource) components.

What problem does it solve?

This Skill eliminates the manual overhead of running ad-hoc SQL against PostgreSQL databases that are containerized. It can automatically locate running PostgreSQL containers and route your queries to the correct database for inspection and modification.

Core Features & Use Cases

  • Automatic container detection: finds running PostgreSQL containers and uses docker exec to reach psql.
  • Support for all SQL operations: executes SELECT, INSERT, UPDATE, and DELETE across databases.
  • Ad-hoc analysis and data modification: ideal for quick data checks, debugging, and validating migrations inside containers.

Quick Start

Run the query tool to execute a SQL statement against a containered PostgreSQL database:

  • Use scripts/query_db.sh <database_name> "<sql_query>" to run a single query.
  • If multiple containers are running, pass the container_id as the third argument.

Frequently Asked Questions about postgres-query

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I run ad-hoc SQL queries against a PostgreSQL database in a Docker container?

You can execute SQL by passing the database name and query string to the query script, which automatically detects the running PostgreSQL container and routes the command via docker exec.

Can I execute INSERT, UPDATE, and DELETE statements on a containerized PostgreSQL database?

Yes, the tool supports SELECT, INSERT, UPDATE, and DELETE operations, allowing you to perform ad-hoc data modification and debugging directly inside the containerized PostgreSQL database.

Do I need psql and Docker installed to query a containerized PostgreSQL database?

Yes, you need both Docker and the PostgreSQL client (psql) installed locally, as the tool relies on docker exec to route your SQL statements through psql inside the targeted container.

What should I do if multiple PostgreSQL containers are running when I need to query a specific database?

If multiple PostgreSQL containers are running, pass the specific container_id as the third argument to the query script to ensure the SQL statement targets the correct database instance.

How does automatic container detection work for PostgreSQL databases running in Docker?

Automatic container detection finds running PostgreSQL containers and uses docker exec to reach psql internally, eliminating the manual overhead of specifying connection parameters for ad-hoc data inspection.

Are there limitations when using docker exec for ad-hoc data inspection in PostgreSQL containers?

The approach is constrained to running containerized PostgreSQL instances and requires the Docker environment with psql available, meaning it cannot query remote non-containerized databases directly.