Skip to content

Instantly share code, notes, and snippets.

@tomfa
Created October 23, 2024 18:45
Show Gist options
  • Save tomfa/78195e0e069ec1ac37a2bb22a6c11693 to your computer and use it in GitHub Desktop.
Save tomfa/78195e0e069ec1ac37a2bb22a6c11693 to your computer and use it in GitHub Desktop.
PSQL to JSON: creating data for tests based on database data
select json_agg(row_to_json(t)) from (select * from "my_table" LIMIT 1) as t;
-- This ⬆️ will return a json of the results, which you could use for test data/mock data, you name it.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment