Prompts that generate SQL queries and schemas.
26votes
1answers
2.2kviews

Prompt for a pandas cleaning script that validates the schema before it trusts the CSV

I get monthly CSV exports from a vendor and the columns silently drift: a header gets renamed, a numeric column arrives with stray $ and commas, dates flip between MM/DD and DD/MM. My old script assum
24votes
2answers
3.0kviews

Prompt that writes the migration AND a reversible down-migration, not just the ALTER

Models are great at spitting out ALTER TABLE statements and terrible at remembering that migrations run on live data with existing rows. I got burned adding a NOT NULL column with no default to a tabl
18votes
2answers
1.6kviews

Prompt for a dedup + latest-record SQL query using window functions with a self-check

Reporting handed me an events table with duplicate rows per entity (late-arriving data, at-least-once delivery) and I needed exactly the latest row per key. The naive GROUP BY + MAX(updatedat) approac
15votes
1answers
2.5kviews

Turning a paragraph of requirements into a Postgres schema with RLS and a migration

I wanted to describe a multi-tenant app in plain English and get back a schema that respects tenancy at the database layer, not just in the app code where one forgotten where orgid = leaks everyone's
13votes
1answers
1.5kviews

SQL rollup prompt that returns chart-ready buckets with zero-filled gaps

My time-series charts had holes: any hour with no events simply didn't exist in the query result, so the line chart connected across gaps and hid outages. The naive "group by hour" prompt never genera