public inbox for [email protected]
help / color / mirror / Atom feedCreating files with testdata
2+ messages / 2 participants
[nested] [flat]
* Creating files with testdata
@ 2025-03-10 18:09 H <[email protected]>
0 siblings, 1 reply; 2+ messages in thread
From: H @ 2025-03-10 18:09 UTC (permalink / raw)
To: PostgreSQL Users Mailing List <[email protected]>
I am developing a complex multi-tenant application in postgresql 16 in Linux. During the development I would like to be able to enter test data into various related tables at any given time for testing purposes.
While this can certainly be accomplished by predefined CTE INSERT statements in an SQL file, I would prefer something more flexible. I am thinking of using a markdown file as a source for these CTE INSERT statements. Specifically, having a certain structure in the markdown file where a given markdown heading level, bullet level etc. would correspond to specific tables and columns.
After entering my test data into the markdown file for the given test scenario, I would then run an awk script or similar to create a SQL file with the various CTE INSERT statements. Howevever, it gets complex since I need to handle 1:N relationships between tables in the markdown file...
I hope the above outline is understandable and am interested in comments and thoughts on my above approach.
Thanks.
^ permalink raw reply [nested|flat] 2+ messages in thread
* Re: Creating files with testdata
@ 2025-03-10 19:22 Francisco Olarte <[email protected]>
parent: H <[email protected]>
0 siblings, 0 replies; 2+ messages in thread
From: Francisco Olarte @ 2025-03-10 19:22 UTC (permalink / raw)
To: H <[email protected]>; +Cc: PostgreSQL Users Mailing List <[email protected]>
On Mon, 10 Mar 2025 at 19:17, H <[email protected]> wrote:
...
> After entering my test data into the markdown file for the given test scenario, I would then run an awk script or similar to create a SQL file with the various CTE INSERT statements. Howevever, it gets complex since I need to handle 1:N relationships between tables in the markdown file...
> I hope the above outline is understandable and am interested in comments and thoughts on my above approach.
I do not think MD would be a good source format. Being a developer I
would recommend taking your favorite scripting language ( perl /
python / lua / js , whatever ), build a big object ( which can be
easily helped by some mini-functions to build a little DSL ) and then
spit sql from it ( for developemewnt it is normally better then using
whatever db connection your language has, as it leaves an
understandable sql script ).
I have done this with perl for some projects, built a driver which
defined several helper functions, then dofile("xx.dat") which returned
a big hash and then a series of loops on the result to write the SQL
in whatever order was neccessary.
Francisco Olarte.
^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2025-03-10 19:22 UTC | newest]
Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2025-03-10 18:09 Creating files with testdata H <[email protected]>
2025-03-10 19:22 ` Francisco Olarte <[email protected]>
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox