Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1trq0p-00A822-4Y for pgsql-general@arkaria.postgresql.org; Tue, 11 Mar 2025 03:10:35 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.94.2) (envelope-from ) id 1trq0n-005jdG-Hg for pgsql-general@arkaria.postgresql.org; Tue, 11 Mar 2025 03:10:33 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1trq0n-005jbG-1f for pgsql-general@lists.postgresql.org; Tue, 11 Mar 2025 03:10:33 +0000 Received: from mout.perfora.net ([74.208.4.197]) by magus.postgresql.org with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1trq0j-0029fX-0N for pgsql-general@lists.postgresql.org; Tue, 11 Mar 2025 03:10:32 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=meddatainc.com; s=s1-ionos; t=1741662627; x=1742267427; i=agents@meddatainc.com; bh=UAdtHx5UBIi4j3dgXG1s95Xc2aLJ2OBdkz/7/wiN4Us=; h=X-UI-Sender-Class:Date:In-Reply-To:References:MIME-Version: Content-Type:Content-Transfer-Encoding:Subject:To:From:Message-ID: cc:content-transfer-encoding:content-type:date:from:message-id: mime-version:reply-to:subject:to; b=pwwbtH2gYqaCkjiDDZzY6ctpQJ/Acdnq4zNqeZtB9wjI/GtcrV8IYK4fa0Eyhu1h elyZQw8InXFyMcea5eJ46Dsa6M4bQHm4yU5fvU53nFqShSdXsa07+AG9qPYiATlcs BG+EMq4ofStqOfiC9zzzsxpodhK3bsynXIXt91snfB8Km6iapWZ9IeL+428MLjfny RpIWeMDzYu7JGtsCOaOTGKBHAoVnZDMkrmeJk1OgWMlfd6PkonJGWOtukRMnBxfTD onAKOxj9Xkiwf2Co7Jk08ntHI6yOg72c3ovpTO5QbFufH1PtLJhWR87D6jsCRe53w 22vw7YA1UM4N/2SjDg== X-UI-Sender-Class: 55c96926-9e95-11ee-ae09-1f7a4046a0f6 Received: from Pixel-3a-XL ([98.115.81.194]) by mrelay.perfora.net (mreueus002 [74.208.5.2]) with ESMTPSA (Nemesis) id 0MAxNa-1tzVVX2CGa-004Ukn for ; Tue, 11 Mar 2025 04:10:27 +0100 Date: Mon, 10 Mar 2025 23:10:25 -0400 User-Agent: K-9 Mail for Android In-Reply-To: References: <84A5765B-1D3C-485B-B852-99D63D53963E@meddatainc.com> <4835994a-aecf-4fef-bb75-9a4c5f6e0ffd@aklaver.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: Creating files with testdata To: pgsql-general@lists.postgresql.org From: H Message-ID: X-Provags-ID: V03:K1:1CJhTulryu8bb775JrjC7GqCnEumnIlvrrqn41WS4nTZajSpzOr d75rOW6hRJWsgMHRmC5DRmXg0DsZZrJW9LgVjbOgy1x1gqhYZ71f083e/lPTcj9vCt1JuRD /9zR4KDm+kOXowAkTHsmVr+00xs+rvVnA/uOGbr3PccfhdFgMq2kCjPd5SW+KOBWITu5I9Z mEzUNGp8gU9VvP+FOC10g== X-Spam-Flag: NO UI-OutboundReport: notjunk:1;M01:P0:+zPPuuj2AK4=;k/6kgx20ehOL3IQ3m70+6NjiimX vXSXsTXqzgYR0u+rbkEs5rKE5e5kweF3ruvWjM8K2GwdiwAdrPxBXEGOIeMLb/UOmLPledw44 HRxHsbW8ZtIFoORER062+qaoAfT5J0FhQrJ5izcuorlFrUQrOanh4+olffO5NxQLWjB+9uM+u rUAciJzmAj92LMNsxwvBVo/ejrmIglwDRt17DT7esZWqxovH+3RZylqv8LC6SOnruvo5BDkPc 9x2R5B/1Z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YQYH2fffPhQsNzlfliCfGZ my0wQPhFxtfgvkR3pjcHRmRC/545D/b6UGp9GOgfFLsVG9z+YsBmCDELeA9BNBhffzT List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On March 10, 2025 3:15:10 PM EDT, H wrote: >On March 10, 2025 2:26:48 PM GMT-04:00, Adrian Klaver > wrote: >> >> >>On 3/10/25 11:09 AM, H wrote: >>> I am developing a complex multi-tenant application in postgresql 16 >>in Linux=2E During the development I would like to be able to enter test >>data into various related tables at any given time for testing >>purposes=2E >>>=20 >>> While this can certainly be accomplished by predefined CTE INSERT >>statements in an SQL file, I would prefer something more flexible=2E I >am >>thinking of using a markdown file as a source for these CTE INSERT >>statements=2E Specifically, having a certain structure in the markdown >>file where a given markdown heading level, bullet level etc=2E would >>correspond to specific tables and columns=2E >> >>Why CTE INSERTs? >> >>>=20 >>> 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=2E Howevever, it gets >complex >>since I need to handle 1:N relationships between tables in the >markdown >>file=2E=2E=2E >>>=20 >>> I hope the above outline is understandable and am interested in >>comments and thoughts on my above approach=2E >>>=20 >>> Thanks=2E >>>=20 >>>=20 > >There are tables referencing each other using randomly generated IDs, >ie=2E those IDs are not known until after the parent table row is >inserted=2E I thought I should give an example of why I need this=2E This is /not/ the= application but might be a useful example: Imagine a very simple Wikipedia-clone=2E You have a couple of DB tables fo= r article subjects in a couple of levels, a table for body text and a coupl= e of different tables for references and for images related to the article = in question=2E References and images are not referenced inline in the body = text but at the end=2E Everything is generated manually, ie the body text is written, various ref= erences added, and a suitable subject area in different levels chosen, all = by an author=2E I want to be able to write this "article", with the appropriate references= , images etc to be done outside this database application=2E My vision is i= t's done in a markdown document where a strict use of heading levels, bulle= t lists etc would correlate with subject areas, body text, references, imag= es and what-nots=2E A script of some kind that can parse markdown then generates the necessary= SQL statements to insert all of this in the appropriate tables, all accord= ing to how the information was laid out in the markdown document=2E My initial thought was to use awk but it's (awk)ward since it is strictly = line/paragraph oriented=2E Pandoc parses markdown very well, generates an A= ST internally and then the output filter should be able to generate complex= SQL statements such as CTEs=2E Hope that might shed some more light on my thought process=2E