postgresql-psql

Orchestrate PostgreSQL database interactions through the psql command-line client.

Updated Sep 16, 2023
One-click install
npx skills add https://github.com/paopp2/dotfiles --skill postgresql-psql-paopp2
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: postgresql-psql
Source: https://github.com/paopp2/dotfiles/tree/main/.claude/skills/postgresql-psql
Command: npx skills add https://github.com/paopp2/dotfiles --skill postgresql-psql-paopp2

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve? This skill eliminates the manual effort and complexity of interacting with PostgreSQL databases via the command line, automating routine administration and development tasks.

Core Features & Use Cases:

  • Comprehensive psql Reference: Access a complete guide to psql commands, meta-commands, and options for efficient database interaction.
  • Automated Scripting & Administration: Leverage examples for connection pooling, health checks, and maintenance scripts to automate routine DBA tasks.
  • Performance & Troubleshooting: Utilize built-in tools for query analysis, performance monitoring, and a detailed troubleshooting guide to quickly resolve issues.

Quick Start: Use the postgresql-psql skill to show me how to connect to a remote PostgreSQL database using SSL.

Frequently Asked Questions about postgresql-psql

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

FAQPage Schema
How do I connect to a remote PostgreSQL database using psql with SSL?

Use psql with SSL connection options: psql -h hostname -U username -d database --set=sslmode=require. The sslmode parameter enforces encrypted connections; psql supports require, prefer, and disable modes depending on your security requirements.

Can I automate PostgreSQL database tasks with psql scripts?

Yes. Write .sql scripts with psql meta-commands (like \copy, \d, \timing) and execute them via psql -f script.sql, or embed commands in bash loops for batch administration, health checks, and routine maintenance across multiple databases.

What's the best way to backup and restore PostgreSQL databases from the command line?

Use pg_dump to export database structure and data to a file (pg_dump dbname > backup.sql), then restore with psql -d dbname -f backup.sql. For large databases, pg_dump's --format=custom option creates compressed binary backups that pg_restore can reload faster.

How do I troubleshoot slow PostgreSQL queries using psql?

Enable query timing with \timing, use EXPLAIN ANALYZE to inspect execution plans, and run \d+ on tables to review indexes and constraints. The psql integrated troubleshooting guide covers performance monitoring commands to identify bottlenecks and locks.

Does psql support batch data import and export operations?

Yes. Use \copy to import/export CSV and text files directly in psql sessions without superuser privileges, or COPY for direct file I/O when running as a database superuser. Both commands handle delimiters, headers, and format options for flexible data movement.

Can I configure psql connection defaults and automate logins with .psqlrc?

Yes. Edit ~/.psqlrc to set default connection variables, prompt formatting, and pager options. Use .pgpass to store credentials securely for passwordless authentication, eliminating manual login prompts across scripted and interactive sessions.