From: Adrian Klaver <adrian.klaver@aklaver.com>
To: Ted Toth <txtoth@gmail.com>
To: pgsql-general@lists.postgresql.org
Subject: Re: plpython/python string formatting
Date: Tue, 16 Aug 2022 16:55:59 -0700
Message-ID: <227fd2d4-678b-8c0e-e78d-07a6bb65fd47@aklaver.com> (raw)
In-Reply-To: <CAFPpqQESdqgk4ZM4n7Rxzh9X1VU77kjOt0xk1SL6rMPmVsVfFQ@mail.gmail.com>
References: <CAFPpqQESdqgk4ZM4n7Rxzh9X1VU77kjOt0xk1SL6rMPmVsVfFQ@mail.gmail.com>
On 8/16/22 16:42, Ted Toth wrote:
> I've just started playing with plpython but ran into a issue when I
> was trying to use standard python string formatting to generate a SQL
> string for example:
> s = "EXECUTE format('CREATE INDEX %s ON %s USING (column_name)' %
> (index_name, table_name))"
>
> but plpython then tried to run the EXECUTE instead of just setting
> variable 's'. Why does this happen?
Best guess is you are seeing cross platform collision with:
https://www.postgresql.org/docs/current/functions-string.html#FUNCTIONS-STRING-FORMAT
Why not?:
s = format('CREATE INDEX %s ON %s USING (column_name)' %
(index_name, table_name))
>
> Ted
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients from your mail client; the link fills in
the headers below: reply via email
Some clients, webmail especially, drop In-Reply-To and References from
a link, and the reply then starts a new thread: use the mbox below.
To: pgsql-general@postgresql.org
Cc: adrian.klaver@aklaver.com, txtoth@gmail.com
Subject: Re: plpython/python string formatting
In-Reply-To: <227fd2d4-678b-8c0e-e78d-07a6bb65fd47@aklaver.com>
References: <CAFPpqQESdqgk4ZM4n7Rxzh9X1VU77kjOt0xk1SL6rMPmVsVfFQ@mail.gmail.com> <227fd2d4-678b-8c0e-e78d-07a6bb65fd47@aklaver.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox