From: | Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com> |
---|---|
To: | Ted Toth <txtoth(at)gmail(dot)com>, pgsql-general(at)lists(dot)postgresql(dot)org |
Subject: | Re: plpython/python string formatting |
Date: | 2022-08-16 23:55:59 |
Message-ID: | 227fd2d4-678b-8c0e-e78d-07a6bb65fd47@aklaver.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
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(dot)klaver(at)aklaver(dot)com
From | Date | Subject | |
---|---|---|---|
Next Message | Adrian Klaver | 2022-08-17 00:23:16 | Re: plpython/python string formatting |
Previous Message | Ted Toth | 2022-08-16 23:42:04 | plpython/python string formatting |