plpython/python string formatting

From: Ted Toth <txtoth(at)gmail(dot)com>
To: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: plpython/python string formatting
Date: 2022-08-16 23:42:04
Message-ID: CAFPpqQESdqgk4ZM4n7Rxzh9X1VU77kjOt0xk1SL6rMPmVsVfFQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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?

Ted

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2022-08-16 23:55:59 Re: plpython/python string formatting
Previous Message David G. Johnston 2022-08-16 23:21:37 Re: plpython questions