Database Query Skill
You have read-only access to the Gertrude PostgreSQL database for querying and analysis.
Connection Information
- Database name:
gertrude
- User:
readonly
- Password: None required
- Connection command:
psql -U readonly -d gertrude
Database Structure
The database uses multiple schemas to organize tables:
- parent: Parent accounts, children, computers, keychains, keys, notifications, etc.
- child: Computer users, blocked apps, iOS devices, tokens, screenshots
- macapp: Keystroke lines, releases, unlock requests
- iosapp: Block groups, rules, device configurations, suspend requests
- macos: App bundle IDs, categories, browsers, identified/unidentified apps
- system: Deleted entities, interesting events, security events, Stripe events
- public: Fluent migrations, jobs metadata
- podcasts: Podcast-related tables
Common Commands
Introspect Schema
# List all tables with their schemas
psql -U readonly -d gertrude -c "\dt"
# List all schemas with privileges
psql -U readonly -d gertrude -c "\dn+"
# Describe a specific table (show columns, types, constraints)
psql -U readonly -d gertrude -c "\d parent.parents"
psql -U readonly -d gertrude -c "\d+ parent.parents" # with more details
# List all columns in a schema
psql -U readonly -d gertrude -c "\d parent.*"
Query Data
# Run a simple query
psql -U readonly -d gertrude -c "SELECT * FROM parent.parents LIMIT 10;"
# Run a formatted query with better output
psql -U readonly -d gertrude -c "SELECT id, email, created_at FROM parent.parents ORDER BY created_at DESC LIMIT 5;"
# Count records
psql -U readonly -d gertrude -c "SELECT COUNT(*) FROM parent.parents;"
# Complex queries with joins (example)
psql -U readonly -d gertrude -c "
SELECT p.email, COUNT(c.id) as num_children
FROM parent.parents p
LEFT JOIN parent.children c ON c.parent_id = p.id
GROUP BY p.email
LIMIT 10;
"
Format Output
# Use expanded display for wide tables
psql -U readonly -d gertrude -c "\x" -c "SELECT * FROM parent.parents LIMIT 1;"
# Export to CSV
psql -U readonly -d gertrude -c "COPY (SELECT * FROM parent.parents LIMIT 10) TO STDOUT WITH CSV HEADER;"
Workflow
- Understand the question: Determine what data or schema information is needed
- Introspect first: Use
\d commands to understand table structure before writing
queries
- Write queries: Construct appropriate SELECT queries to answer the question
- Analyze results: Interpret the query results and provide clear explanations
- Verify permissions: If you attempt any write operation, you'll get a permission
error (this is expected)
Important Notes
- Read-only access: You cannot INSERT, UPDATE, DELETE, or modify the database in any
way
- Schema qualification: Always use schema-qualified table names (e.g.,
parent.parents, not just parents)
- Query carefully: Start with small LIMIT clauses to avoid overwhelming output
- Explain results: After running queries, provide clear explanations of what the data
shows
Examples
Example 1: How many parents are in the system?
psql -U readonly -d gertrude -c "SELECT COUNT(*) as total_parents FROM parent.parents;"
Example 2: What are the recent security events?
psql -U readonly -d gertrude -c "
SELECT id, event_type, detail, created_at
FROM system.security_events
ORDER BY created_at DESC
LIMIT 10;
"
Example 3: What columns are in the computers table?
psql -U readonly -d gertrude -c "\d parent.computers"
Converted and distributed by TomeVault — claim your Tome and manage your conversions.
1---2name: database-33description: You have read-only access to the Gertrude PostgreSQL database for querying and analysis. Use when this capability is needed.4---56# Database Query Skill78You have read-only access to the Gertrude PostgreSQL database for querying and analysis.910## Connection Information1112- **Database name**: `gertrude`13- **User**: `readonly`14- **Password**: None required15- **Connection command**: `psql -U readonly -d gertrude`1617## Database Structure1819The database uses multiple schemas to organize tables:2021- **parent**: Parent accounts, children, computers, keychains, keys, notifications, etc.22- **child**: Computer users, blocked apps, iOS devices, tokens, screenshots23- **macapp**: Keystroke lines, releases, unlock requests24- **iosapp**: Block groups, rules, device configurations, suspend requests25- **macos**: App bundle IDs, categories, browsers, identified/unidentified apps26- **system**: Deleted entities, interesting events, security events, Stripe events27- **public**: Fluent migrations, jobs metadata28- **podcasts**: Podcast-related tables2930## Common Commands3132### Introspect Schema3334```bash35# List all tables with their schemas36psql -U readonly -d gertrude -c "\dt"3738# List all schemas with privileges39psql -U readonly -d gertrude -c "\dn+"4041# Describe a specific table (show columns, types, constraints)42psql -U readonly -d gertrude -c "\d parent.parents"43psql -U readonly -d gertrude -c "\d+ parent.parents" # with more details4445# List all columns in a schema46psql -U readonly -d gertrude -c "\d parent.*"47```4849### Query Data5051```bash52# Run a simple query53psql -U readonly -d gertrude -c "SELECT * FROM parent.parents LIMIT 10;"5455# Run a formatted query with better output56psql -U readonly -d gertrude -c "SELECT id, email, created_at FROM parent.parents ORDER BY created_at DESC LIMIT 5;"5758# Count records59psql -U readonly -d gertrude -c "SELECT COUNT(*) FROM parent.parents;"6061# Complex queries with joins (example)62psql -U readonly -d gertrude -c "63 SELECT p.email, COUNT(c.id) as num_children64 FROM parent.parents p65 LEFT JOIN parent.children c ON c.parent_id = p.id66 GROUP BY p.email67 LIMIT 10;68"69```7071### Format Output7273```bash74# Use expanded display for wide tables75psql -U readonly -d gertrude -c "\x" -c "SELECT * FROM parent.parents LIMIT 1;"7677# Export to CSV78psql -U readonly -d gertrude -c "COPY (SELECT * FROM parent.parents LIMIT 10) TO STDOUT WITH CSV HEADER;"79```8081## Workflow82831. **Understand the question**: Determine what data or schema information is needed842. **Introspect first**: Use `\d` commands to understand table structure before writing85 queries863. **Write queries**: Construct appropriate SELECT queries to answer the question874. **Analyze results**: Interpret the query results and provide clear explanations885. **Verify permissions**: If you attempt any write operation, you'll get a permission89 error (this is expected)9091## Important Notes9293- **Read-only access**: You cannot INSERT, UPDATE, DELETE, or modify the database in any94 way95- **Schema qualification**: Always use schema-qualified table names (e.g.,96 `parent.parents`, not just `parents`)97- **Query carefully**: Start with small LIMIT clauses to avoid overwhelming output98- **Explain results**: After running queries, provide clear explanations of what the data99 shows100101## Examples102103### Example 1: How many parents are in the system?104105```bash106psql -U readonly -d gertrude -c "SELECT COUNT(*) as total_parents FROM parent.parents;"107```108109### Example 2: What are the recent security events?110111```bash112psql -U readonly -d gertrude -c "113 SELECT id, event_type, detail, created_at114 FROM system.security_events115 ORDER BY created_at DESC116 LIMIT 10;117"118```119120### Example 3: What columns are in the computers table?121122```bash123psql -U readonly -d gertrude -c "\d parent.computers"124```125126---127> Converted and distributed by [TomeVault](https://tomevault.io/claim/gertrude-app) — claim your Tome and manage your conversions.128<!-- tomevault:4.0:skill_md:2026-04-11 -->