Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oO6Pn-0002Ey-LK for pgsql-general@arkaria.postgresql.org; Tue, 16 Aug 2022 23:56:07 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1oO6Pm-0000Ws-Hl for pgsql-general@arkaria.postgresql.org; Tue, 16 Aug 2022 23:56:06 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oO6Pm-0000Wj-70 for pgsql-general@lists.postgresql.org; Tue, 16 Aug 2022 23:56:06 +0000 Received: from out5-smtp.messagingengine.com ([66.111.4.29]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1oO6Ph-0006WP-DI for pgsql-general@lists.postgresql.org; Tue, 16 Aug 2022 23:56:05 +0000 Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 8F6EA5C00AF; Tue, 16 Aug 2022 19:56:00 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute2.internal (MEProxy); Tue, 16 Aug 2022 19:56:00 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm3; t=1660694160; x= 1660780560; bh=TNyFBMG26MlZyREEaHOvZ+IMZ7t40DNz+gJPtmPuHTw=; b=P +yfaY2pkR3BhvAOcjCYALpxxCKSbIUzFpx2WkBJafByhSvyZF0C2fSDDtW4OZg1O gf//GMAFm2lBKAqqkWVozE+kWxNWk6uzPdd8qthzHL7DtEwzmbCFZTQ5mzJ2TXJr /qCGCMuk7xChsvtMDEHDhPtsbnkzWl3u2IzQ2TZQJVd95yJ/v43Ng36QATkhk8NV 5KLTRBdKbU7JLSZBp2vrpHgyIFSuvXBSW1vCw9/IUT5LbIy4hWKeb5shu6ehr8s9 cgeAc8Rfkxy2gUg+w5zC2wQAPGwvnHB9UR7Bbi0oimTIcABgxsfvk/NSEdUX6DGB qilv0EFv03eqFfmowAw2A== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:date:feedback-id:feedback-id:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to:x-me-proxy:x-me-proxy:x-me-sender :x-me-sender:x-sasl-enc; s=fm1; t=1660694160; x=1660780560; bh=T NyFBMG26MlZyREEaHOvZ+IMZ7t40DNz+gJPtmPuHTw=; b=XmZl9yNDd85eYELZC Cucsod/S4KJsj+0FTcxworLRetULaf+GDFJaamLfhWhhaJ0w15m6N7c56Fgpl1/L HI4mj1iEwqTDDmnX7GEIoldE4e1knpcCYM0I2tH9WQpmOuYBRmG3NqWuPworJFu5 s64BKnHjBkbV4yJ5oRn93/U8FlFUDrkCLp5DdU01YRTxvrIKYNHCPms3DVIE9fJ1 YlZTeJsD0kjF5mdoJkhYysJKZ5WWS1AhplBOKuEXz8Y9CcWxh5xSYLYOXbFD9qEb 4tJjY2XOZmjAyk2wN77C4gJISQCM7C7Om6NVgLeF+YYT6w/SPxDmmMjmeaV8kcCJ GVkZQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvfedrvdehhedgvdejucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepkfffgggfuffvfhfhjggtgfesthejredttdefjeenucfhrhhomheptegurhhi rghnucfmlhgrvhgvrhcuoegrughrihgrnhdrkhhlrghvvghrsegrkhhlrghvvghrrdgtoh hmqeenucggtffrrghtthgvrhhnpeffudehtddugefgkeevudffheevvefhfeettdfhveei vdfgieeghfeiueeggffggeenucffohhmrghinhepphhoshhtghhrvghsqhhlrdhorhhgne cuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprggurhhi rghnrdhklhgrvhgvrhesrghklhgrvhgvrhdrtghomh X-ME-Proxy: Feedback-ID: i76984098:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Tue, 16 Aug 2022 19:55:59 -0400 (EDT) Message-ID: <227fd2d4-678b-8c0e-e78d-07a6bb65fd47@aklaver.com> Date: Tue, 16 Aug 2022 16:55:59 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.12.0 Subject: Re: plpython/python string formatting Content-Language: en-US To: Ted Toth , pgsql-general@lists.postgresql.org References: From: Adrian Klaver In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk 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