본문으로 건너뛰기
Skillpedia
데이터베이스48k · #6291

postgres-readonly-queries

하는 일

이 에이전트는 PostgreSQL 데이터베이스에 안전하게 질문하고 데이터만 읽도록 합니다. 설정한 여러 데이터베이스에 연결하며, 실수로 아무것도 바꾸지 않도록 합니다.

사용하는 경우

  • ✓변경될 위험 없이 PostgreSQL 데이터베이스의 데이터를 보아야 할 때.
  • ✓데이터베이스의 테이블과 열을 살펴볼 때.
  • ✓고객이나 주문 목록처럼 데이터베이스의 특정 정보를 확인하는 경우.

스킬 링크

https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/postgres-readonly-queries/SKILL.md

복사해서 AI(Claude, ChatGPT, Cursor)에 붙여넣고 지침을 따르도록 요청하세요.

사용 방법

가장 쉬운 방법입니다. 메시지를 복사해 AI에 붙여넣으세요. AI가 스킬을 읽고 지침을 따릅니다.

바로 붙여넣을 수 있는 메시지

Use this skill to help me: https://github.com/sickn33/agentic-awesome-skills/blob/main/skills/postgres-readonly-queries/SKILL.md Read the SKILL.md file at that link and follow its instructions for my task.
AI가 이런 스킬을 알아서 찾아 쓰길 원하시나요?무료 Skillpedia MCP를 설치하세요. 한 줄이면 작업마다 스킬 15,000+개 중에서 검색합니다.1분 만에 설치 →

AI에게 요청하는 예시

“운영 데이터베이스에서 사용자 처음 10명을 나열해 주세요.”

매주 새 스킬 5개. 읽는 데 1분.

작동 방식

파일에 PostgreSQL 데이터베이스의 연결 정보를 설정합니다. 그다음 에이전트에게 SQL 쿼리(데이터를 가져오는 명령)를 실행하도록 요청할 수 있으며, 이 쿼리는 항상 읽기 전용이라 안전합니다.

기술 내용 (원본 SKILL.md)

작성자의 영어 원문을 GitHub에서 그대로 가져왔습니다.

PostgreSQL Read-Only Query Skill

When to Use

  • Use when querying PostgreSQL databases and access must stay strictly read-only
  • Use when exploring schemas, tables, and data across multiple configured connections
  • Use when you want defense-in-depth protection against accidental INSERT/UPDATE/DELETE or DDL

Execute safe, read-only queries against configured PostgreSQL databases.

Requirements

  • Python 3.8+
  • psycopg2-binary: pip install -r requirements.txt

Setup

Create connections.json in the skill directory or ~/.config/claude/postgres-connections.json.

Security: Set file permissions to 600 since it contains credentials:

chmod 600 connections.json
{
  "databases": [
    {
      "name": "production",
      "description": "Main app database - users, orders, transactions",
      "host": "db.example.com",
      "port": 5432,
      "database": "app_prod",
      "user": "readonly_user",
      "password": "your-password",
      "sslmode": "require"
    }
  ]
}

Config Fields

Field Required Description
name Yes Identifier for the database (case-insensitive)
description Yes What data this database contains (used for auto-selection)
host Yes Database hostname
port No Port number (default: 5432)
database Yes Database name
user Yes Username
password Yes Password
sslmode No SSL mode: disable, allow, prefer (default), require, verify-ca, verify-full

Usage

List configured databases

python3 scripts/query.py --list

Query a database

python3 scripts/query.py --db production --query "SELECT * FROM users LIMIT 10"

List tables

python3 scripts/query.py --db production --tables

Show schema

python3 scripts/query.py --db production --schema

Limit results

python3 scripts/query.py --db production --query "SELECT * FROM orders" --limit 100

Database Selection

Match user intent to database description:

User asks about Look for description containing
users, accounts users, accounts, customers
orders, sales orders, transactions, sales
analytics, metrics analytics, metrics, reports
logs, events logs, events, audit

If unclear, run --list and ask user which database.

Safety Features

  • Read-only session: Connection uses PostgreSQL readonly=True mode (primary protection)
  • Query validation: Only SELECT, SHOW, EXPLAIN, WITH queries allowed
  • Single statement: Multiple statements per query rejected
  • SSL support: Configurable SSL mode for encrypted connections
  • Query timeout: 30-second statement timeout enforced
  • Memory protection: Max 10,000 rows per query to prevent OOM
  • Column width cap: 100 char max per column for readable output
  • Credential sanitization: Error messages don't leak passwords

Troubleshooting

Error Solution
Config not found Create connections.json in skill directory
Authentication failed Check username/password in config
Connection timeout Verify host/port, check firewall/VPN
SSL error Try "sslmode": "disable" for local databases
Permission warning Run chmod 600 connections.json

Exit Codes

  • 0: Success
  • 1: Error (config missing, auth failed, invalid query, database error)

Workflow

  1. Run --list to show available databases
  2. Match user intent to database description
  3. Run --tables or --schema to explore structure
  4. Execute query with appropriate LIMIT

Limitations

  • Read-only protections reduce accidental writes but cannot override database-server policy, triggers, extensions, or an over-privileged account. Use a database role with read-only permissions as the primary control.
  • Query results can contain personal, confidential, or regulated data. Confirm the intended database and avoid exporting or sharing results without explicit authorization.
  • The script is not a replacement for backups, auditing, access reviews, or production change controls.
자주 묻는 질문

데이터를 바꾸려고 하면 어떻게 되나요?

에이전트는 변경을 막도록 설계되어 있습니다. SELECT 같은 읽기 명령만 허용하며, 실수로 데이터를 수정하거나 삭제하지 못하도록 추가 보호 장치가 있습니다.

에이전트는 어떤 데이터베이스에 연결할지 어떻게 아나요?

설정된 데이터베이스 목록을 보고 이름이나 설명으로 하나를 고를 수 있습니다. 에이전트는 질문을 바탕으로 어떤 데이터베이스를 원하는지 추측하기도 합니다.

제 비밀번호를 넣어도 안전한가요?

예, 보안 지침을 따른다면 안전합니다. 비밀번호는 사용자만 읽고 쓸 수 있도록 제한된 권한을 가진 특별한 설정 파일에 들어 있으며, 에이전트는 오류 메시지에 비밀번호를 표시하지 않습니다.

상세 정보

작성자의 원본 설명

Execute safe read-only SQL queries against PostgreSQL databases with multi-connection support and defense-in-depth write protection.

repo: sickn33/agentic-awesome-skills

인기도

GitHub 스타
48k
순위
#6291
라이선스
MIT
업데이트
2026. 10. 15.

이 스킬이 유용한가요?

0

로그인 투표하려면 로그인하세요.

댓글

  • …

이 저장소의 다른 스킬

비슷한 스킬