Connect to and run queries against the PPR live replica MySQL database (hnddb). Use this skill when the user asks to query PPR live data, look up shops, agents, rounds, deliveries, activity logs, or any production PPR data. Also covers the Mercury config variant.
The PPR live system uses a MySQL database called hnddb (743 tables). Query scripts in the support directory handle credential fetching from AWS SSM and connection automatically.
~/ws/ppr/tech/tools/hnddb-queries/query-db.ts (SSM param: /appconfig/live)~/ws/ppr/tech/tools/hnddb-queries/query-mercury.ts (SSM param: /appconfig/mercury)~/ws/ppr/tech/tools/hnddb-queries/query-db.ts for most queries. query-mercury.ts uses a different credential path but same database.aws sso login --profile paperroundcd ~/ws/ppr/tech/tools/hnddb-queries && npm install# Direct execution (most common)
npx tsx ~/ws/ppr/tech/tools/hnddb-queries/query-db.ts "SELECT * FROM shops LIMIT 5"
# Via npm script
cd ~/ws/ppr/tech/tools/hnddb-queries && npm run query -- "SELECT * FROM shops LIMIT 5"
# With bastion tunnel
DB_USE_TUNNEL=1 DB_TUNNEL_PORT=3306 npx tsx ~/ws/ppr/tech/tools/hnddb-queries/query-db.ts "SELECT ..."
/appconfig/live or /appconfig/mercury) from eu-west-1 with decryptionreadonlydb (replica host) and update_user_escaped (user:password)hnddbupdate_user_escaped used because readonly user has IP restrictionseu-west-1 (not eu-west-2)DESCRIBE <table_name> or SHOW TABLES LIKE '%keyword%'The data model documentation is split into domain-specific files in this skill directory. Read the relevant file(s) before writing queries to understand table schemas, relationships, and lookup values.
data-model-core.md — Core entities: shops, customers, publications, publicationprices, customerpublications, days lookup, delivery persons, agents, financial transactions, addresses, key relationships, common query patternsdata-model-rounds.md — Full rounds domain: round structure & config, membership & ordering, delivery person assignment (intended vs actual, 5 layers), payment configuration (paybands, frequencies, extras), actual deliveries (deliveryhistory → rounddeliveries → rounddeliverypublications), delivery app (deliverydrop with GPS), training rounds (lifecycle, completion, controls, rules), split rounds, charges, delivery frequency, contractor typesdata-model-delivery-persons.md — Delivery persons domain: core deliverypersons table (status/lifecycle, type, payment fields, delivery app link), contractortypes lookup, deliverypersongroups, all tables referencing deliverypersonid (round assignment, actual deliveries, payments, collections, route optimisation, training), common query patternsdata-model-activity-logs.md — Activity/logging domain: user login trail, delivery app logs, shop command logs, customer/shop/account audit trails, email logs, and common filtering patterns by user/date/entitydata-model-packing.md — Packing domain: pack site hierarchy (hubs/child sites, nested set), bundle config per publication/day, title sets, cages, supplier priorities, publication routing overrides, report sheet types (Bundles/Title Sets/Spares/Totals/Cages)To read a file, use its path relative to this skill: ~/.agents/skills/ppr-live-db/<filename>
data-model-core.mddata-model-rounds.mddata-model-delivery-persons.mddata-model-core.mddata-model-rounds.md and data-model-delivery-persons.mddata-model-rounds.mddata-model-activity-logs.mddata-model-packing.md